Documentation
¶
Overview ¶
Package log defines the logger engine. The unique feature is that it can create a child logger derived from the parent logger. Each logger defines a unique color style for the message outputs.
Create a child logger for the packages that the service is calling.
Index ¶
- func Fatal(title string, kv ...interface{})
- type Logger
- func (logger *Logger) Child(prefix string, kv ...interface{}) *Logger
- func (logger *Logger) Error(title string, kv ...interface{})
- func (logger *Logger) Fatal(title string, kv ...interface{})
- func (logger *Logger) Info(title string, kv ...interface{})
- func (logger *Logger) Prefix() string
- func (logger *Logger) Warn(title string, kv ...interface{})
- func (logger *Logger) Write(data []byte) (int, error)
- type LoggerStyle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the wrapper over the logger and keeps the style. The style is generated randomly.
func (*Logger) Child ¶
Child logger from the parent with its own color style.
When to use it?
For example:
parent, _ := log.New("main", false) db_log, _ := parent.Child("database") reply, _ := parent.Child("server") parent.Info("starting", "security_enabled", true) db_log.Info("starting") reply.Info("starting", "port", 443) // prints the following // INFO main: starting: security_enabled=true // INFO main::database: starting // INFO main::server: starting, port=443
type LoggerStyle ¶
type LoggerStyle struct {
// contains filtered or unexported fields
}
LoggerStyle defines the various colors for each log parts.
Click to show internal directories.
Click to hide internal directories.