Documentation
¶
Index ¶
- Constants
- func AddAppender(appenderName string, output io.Writer, logLevel Level, format string, ...)
- func AddFileAppender(appenderName string, filePath string, logLevel Level, format string, ...)
- func Debug(fmtmsg string, a ...interface{})
- func DebugKV(msg string, keyvals map[string]interface{})
- func Disable()
- func Enable()
- func Error(fmtmsg string, a ...interface{})
- func ErrorKV(msg string, keyvals map[string]interface{})
- func Fatal(fmtmsg string, a ...interface{})
- func FatalKV(msg string, keyvals map[string]interface{})
- func Info(fmtmsg string, a ...interface{})
- func InfoKV(msg string, keyvals map[string]interface{})
- func Panic(fmtmsg string, a ...interface{})
- func PanicKV(msg string, keyvals map[string]interface{})
- func RemoveAppender(appenderNameToRemove string)
- func SetAppenders(appenders map[string]*Appender)
- func SetGlobalConfig(config *Config)
- func SetGlobalLogLevel(level Level)
- func SetOutputFlags(flags *OutputFlags)
- func SetTimestampFormat(format string)
- func Warn(fmtmsg string, a ...interface{})
- func WarnKV(msg string, keyvals map[string]interface{})
- type Appender
- type Config
- type Level
- type Logger
- type OutputFlags
- type Provider
Constants ¶
const ( // JsonFmt indicates that log output generated in form of JSON. JsonFmt string = "JSON" // TextFmt indicates that log output generated in form of TEXT. TextFmt string = "TEXT" // ConsoleLog indicates that log output to console. ConsoleLog string = "CONSOLE_LOG" // FileLog indicates that log output to console. FileLog string = "FILE_LOG" // ConsoleStdout indicates than console log output to os.Stdout ConsoleStdout string = "STDOUT" // ConsoleStderr indicates than console log output to os.Stderr ConsoleStderr string = "STDERR" )
Variables ¶
This section is empty.
Functions ¶
func AddAppender ¶
func AddAppender(appenderName string, output io.Writer, logLevel Level, format string, showCaller bool, showHostname bool)
AddAppender adds/replaces a new logging destination.
func AddFileAppender ¶
func AddFileAppender(appenderName string, filePath string, logLevel Level, format string, showCaller bool, showHostname bool)
AddFileAppender adds/replaces a new logging destination that append logs to a specified file.
func RemoveAppender ¶
func RemoveAppender(appenderNameToRemove string)
RemoveAppender removes a logging appender by name.
func SetAppenders ¶
SetAppenders sets a set of "Appenders".
func SetGlobalConfig ¶
func SetGlobalConfig(config *Config)
SetGlobalConfig is used to refresh logging manners.
func SetGlobalLogLevel ¶
func SetGlobalLogLevel(level Level)
SetGlobalLogLevel is used to restraint log-level of all "Appenders".
func SetOutputFlags ¶
func SetOutputFlags(flags *OutputFlags)
SetOutputFlags is used to reconfig output flags.
func SetTimestampFormat ¶
func SetTimestampFormat(format string)
Types ¶
type Appender ¶
type Appender struct {
Enabled bool
LogLevel Level
LogType string
LogPath string
Output io.Writer
Format string
ShowCaller bool
ShowHostname bool
}
Appender is responsible for delivering LogEvents to their destination.
type Config ¶
type Config struct {
Enabled bool
Provider Provider
GlobalLogLevel Level
TimeFieldFormat string
Appenders map[string]*Appender
OutputFlags *OutputFlags
}
Config includes configurations for our log, such as log-level. For more log destinations just add "Appender" into "Config.[]Appenders".
func GetGlobalConfig ¶
func GetGlobalConfig() *Config
type Level ¶
type Level uint8
Level defines log levels.
const ( // DebugLevel defines debug log level. DebugLevel Level = iota // InfoLevel defines info log level. InfoLevel // WarnLevel defines warn log level. WarnLevel // ErrorLevel defines error log level. ErrorLevel // FatalLevel defines fatal log level. FatalLevel // PanicLevel defines panic log level. PanicLevel // Disabled disables the logger. Disabled )
func GetGlobalLogLevel ¶
func GetGlobalLogLevel() Level
type Logger ¶
type Logger interface {
Debug(msg string)
Info(msg string)
Warn(msg string)
Error(msg string)
Fatal(msg string)
Panic(msg string)
DebugKV(msg string, keyvals map[string]interface{})
InfoKV(msg string, keyvals map[string]interface{})
WarnKV(msg string, keyvals map[string]interface{})
ErrorKV(msg string, keyvals map[string]interface{})
FatalKV(msg string, keyvals map[string]interface{})
PanicKV(msg string, keyvals map[string]interface{})
SetGlobalLogLevel(level Level)
SetOutputFlags(flags *OutputFlags)
SetTimeFieldFormat(format string)
}
Logger interface defines all behaviors of a backendLogger.
type OutputFlags ¶
type OutputFlags struct {
// TimestampFieldName is the field name used for the timestamp field.
TimestampFieldName string
// LevelFieldName is the field name used for the level field.
LevelFieldName string
// MessageFieldName is the field name used for the message field.
MessageFieldName string
// ErrorFieldName is the field name used for error fields.
ErrorFieldName string
// CallerFieldName is the field name used for caller field.
CallerFieldName string
// HostnameFieldName is the field name used for hostname field.
HostnameFieldName string
}
OutputFlags are printed in log record that can be customized.
func GetOutputFlags ¶
func GetOutputFlags() *OutputFlags