Documentation
¶
Index ¶
- Variables
- func AddAdditionalExpVars(config *Config)
- func CheckErr(err error)
- func GetInspectData(config Config) string
- func LogDebug(format string, args ...interface{})
- func LogError(format string, args ...interface{})
- func LogFatal(format string, args ...interface{})
- func LogInfo(format string, args ...interface{})
- func LogWarn(format string, args ...interface{})
- func Maxf64(v []float64) float64
- func Minf64(v []float64) float64
- func ReadConfig(cfg *Config, supersedefilename ...string)
- type Config
- type Flags
- type LogLevel
- type Logger
- func (l *Logger) Debug(format string, args ...interface{})
- func (l *Logger) Error(format string, args ...interface{})
- func (l *Logger) Fatal(format string, args ...interface{})
- func (l *Logger) Info(format string, args ...interface{})
- func (l *Logger) SetConvenienceLogger()
- func (l *Logger) Warn(format string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
var ( //Version is a linker injected variable for a git revision info used as version info Version = "Unknown build" /*Buildstamp is a linker injected variable for a buildtime timestamp used in version info */ Buildstamp = "unknown build timestamp." )
Functions ¶
func AddAdditionalExpVars ¶
func AddAdditionalExpVars(config *Config)
AddAdditionalExpVars extends the standard expvars (see https://golang.org/pkg/expvar/ ) by some environment variables and config data.
func CheckErr ¶
func CheckErr(err error)
CheckErr is a convenience function makes error handling dangerously simple.
func GetInspectData ¶
GetInspectData offer some additional debugging information
func LogDebug ¶
func LogDebug(format string, args ...interface{})
LogDebug works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It usses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set higher or equal to 'Debug'
func LogError ¶
func LogError(format string, args ...interface{})
LogError works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It usses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set higher or equal to 'Error'
func LogFatal ¶
func LogFatal(format string, args ...interface{})
LogFatal works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It usses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set hogher or equal to 'Fatal'
func LogInfo ¶
func LogInfo(format string, args ...interface{})
LogInfo works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It usses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set higher or equal to 'Info'
func LogWarn ¶
func LogWarn(format string, args ...interface{})
LogWarn works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It usses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set higher or equal to 'Warn'
Types ¶
type Config ¶
type Config struct { DataBase struct { Database string User string Password string } Log struct { LogLevel string ActiveLogLevel LogLevel LogFileName string Logger *Logger } ConfigFile string BuildTimeStamp time.Time GitVersion string }
Config contains the configuration data.
type Flags ¶
type Flags struct { ConfigFile string Database string User string Password string LogLevel string LogFileName string }
Flags ...
type LogLevel ¶
type LogLevel int
LogLevel sets the criticality of a logging output. It is used to filter logging messages depending on their priority. Compare to log4j.
The predefined LogLevels that are used by the logging funktions below.
func LogLevelString ¶
LogLevelString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func LogLevelValues ¶
func LogLevelValues() []LogLevel
LogLevelValues returns all values of the enum
func (LogLevel) IsALogLevel ¶
IsALogLevel returns "true" if the value is listed in the enum definition. "false" otherwise
type Logger ¶
type Logger struct { ActiveLoglevel LogLevel // contains filtered or unexported fields }
A Logger is an onbject the offers several method to write Messages to a stream. Atually it is a wrapper aroung the 'log' package, that enhances the LogLevel functionality.
func NewLogger ¶
NewLogger creates a new Logger. It take a string file name as output file and a LogLevel to filter the messages that are wanted. The logger will use io.StdOut if the log filename string parameter is "STDOUT"
func NewLoggerFromFile ¶
NewLoggerFromFile creates a new Logger. It take a file parameter (io.Writer) output file and a LogLevel to filter the messages that are wanted. The first created logger wil be set to be the convenience logger (see the convenience functions Log...() below). Afterwards created loggers will not overwrie this. The convenience logger can be reset by using the method SetConvenienceLogger.
func (*Logger) Debug ¶
Debug works just as fmt.Printf, but prints into the loggers stream. The message is only printed if ActiveLogLevel is set higher or equal to 'Debug'
func (*Logger) Error ¶
Error works just as fmt.Printf, but prints into the loggers stream. The message is only printed if ActiveLogLevel is set higher or equal to 'Error'
func (*Logger) Fatal ¶
Fatal works just as fmt.Printf, but prints into the loggers stream. The message is only printed if ActiveLogLevel is set hogher or equal to 'Fatal'
func (*Logger) Info ¶
Info works just as fmt.Printf, but prints into the loggers stream. The message is only printed if ActiveLogLevel is set higher or equal to 'Info'
func (*Logger) SetConvenienceLogger ¶
func (l *Logger) SetConvenienceLogger()
SetConvenienceLogger sets a logger as a singleton object. The LogInfo etc. functions use this singleton to offer logging function without an object context.