Documentation ¶
Index ¶
- Variables
- type BasicLogger
- func (b *BasicLogger) LogDebug(fields map[string]interface{}, format string, args ...interface{})
- func (b *BasicLogger) LogError(fields map[string]interface{}, format string, args ...interface{})
- func (b *BasicLogger) LogFatal(fields map[string]interface{}, format string, args ...interface{})
- func (b *BasicLogger) LogInfo(fields map[string]interface{}, format string, args ...interface{})
- func (b *BasicLogger) LogWarn(fields map[string]interface{}, format string, args ...interface{})
- func (b *BasicLogger) NewLogger(component string) Logger
- func (b *BasicLogger) SetLogLevel(level Level) Logger
- type Config
- type Level
- type Logger
Constants ¶
This section is empty.
Variables ¶
View Source
var ( LevelDebug = Level{Name: "debug", Color: color.FgWhite, Index: 0, Writer: os.Stdout} LevelInfo = Level{Name: "info", Color: color.FgWhite, Index: 1, Writer: os.Stdout} LevelWarn = Level{Name: "warn", Color: color.FgYellow, Index: 2, Writer: os.Stderr} LevelError = Level{Name: "error", Color: color.FgHiRed, Index: 3, Writer: os.Stderr} LevelFatal = Level{Name: "fatal", Color: color.FgRed, Index: 4, Writer: os.Stderr} )
defines a set of log level
Functions ¶
This section is empty.
Types ¶
type BasicLogger ¶
type BasicLogger struct {
// contains filtered or unexported fields
}
BasicLogger simply implements Logger
func (*BasicLogger) LogDebug ¶
func (b *BasicLogger) LogDebug(fields map[string]interface{}, format string, args ...interface{})
LogDebug print a message with debug level.
func (*BasicLogger) LogError ¶
func (b *BasicLogger) LogError(fields map[string]interface{}, format string, args ...interface{})
LogError print a message with error level.
func (*BasicLogger) LogFatal ¶
func (b *BasicLogger) LogFatal(fields map[string]interface{}, format string, args ...interface{})
LogFatal print a message with fatal level.
func (*BasicLogger) LogInfo ¶
func (b *BasicLogger) LogInfo(fields map[string]interface{}, format string, args ...interface{})
LogInfo print a message with info level.
func (*BasicLogger) LogWarn ¶
func (b *BasicLogger) LogWarn(fields map[string]interface{}, format string, args ...interface{})
LogWarn print a message with warn level.
func (*BasicLogger) NewLogger ¶
func (b *BasicLogger) NewLogger(component string) Logger
NewLogger is used to derive a new child Logger
func (*BasicLogger) SetLogLevel ¶
func (b *BasicLogger) SetLogLevel(level Level) Logger
SetLogLevel is used to set log level
type Logger ¶
type Logger interface { // LogDebug print a message with debug level. LogDebug(fields map[string]interface{}, format string, args ...interface{}) // LogInfo print a message with info level. LogInfo(fields map[string]interface{}, format string, args ...interface{}) // LogWarn print a message with warn level. LogWarn(fields map[string]interface{}, format string, args ...interface{}) // LogError print a message with error level. LogError(fields map[string]interface{}, format string, args ...interface{}) // LogFatal print a message with fatal level. LogFatal(fields map[string]interface{}, format string, args ...interface{}) // NewLogger is used to derive a new child Logger NewLogger(component string) Logger // SetLogLevel is used to set log level SetLogLevel(level Level) Logger }
Logger defines the basic log library implementation
func New ¶
func New(cfg *Config, component string, registerer prometheus.Registerer) (Logger, error)
New is used to init service
func NewDefault ¶
NewDefault is used to initialize a simple Logger
Click to show internal directories.
Click to hide internal directories.