Documentation ¶
Overview ¶
Package log implements a simple logging package.
Index ¶
- Variables
- func Debug(v ...interface{})
- func Debugf(f string, v ...interface{})
- func Error(v ...interface{})
- func Errorf(f string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(f string, v ...interface{})
- func Info(v ...interface{})
- func Infof(f string, v ...interface{})
- func Panic(v ...interface{})
- func Panicf(f string, v ...interface{})
- func Warn(v ...interface{})
- func Warnf(f string, v ...interface{})
- type DefaultLogFormatter
- type Fields
- type Formatter
- type JSONFormatter
- type JSONLogFormatter
- type Level
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(f string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(f string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(f string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(f string, v ...interface{})
- func (l *Logger) Panic(v ...interface{})
- func (l *Logger) Panicf(f string, v ...interface{})
- func (l *Logger) SetFormatter(f Formatter)
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) SetWriter(w io.Writer)
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(f string, v ...interface{})
- func (l *Logger) WithField(key string, value interface{}) *Logger
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultFormatter - default log formatter. DefaultFormatter = new(DefaultLogFormatter) // StdLog - default log StdLog = New(os.Stderr, DefaultFormatter, Fields{}) )
var LevelStrings = map[string]Level{ "debug": DebugLevel, "info": InfoLevel, "warn": WarnLevel, "error": ErrorLevel, "fatal": FatalLevel, "panic": PanicLevel, }
LevelStrings - to return level type by level name
var Strings = [...]string{
DebugLevel: "DEBUG",
InfoLevel: "INFO",
WarnLevel: "WARN",
ErrorLevel: "ERROR",
FatalLevel: "FATAL",
PanicLevel: "PANIC",
}
Strings mapping.
Functions ¶
func Debugf ¶
func Debugf(f string, v ...interface{})
Debugf calls log to print to the standard logger.
func Errorf ¶
func Errorf(f string, v ...interface{})
Errorf calls log to print to the standard logger.
func Fatalf ¶
func Fatalf(f string, v ...interface{})
Fatalf calls log to print to the standard logger.
func Infof ¶
func Infof(f string, v ...interface{})
Infof calls log to print to the standard logger.
Types ¶
type DefaultLogFormatter ¶
type DefaultLogFormatter struct {
// contains filtered or unexported fields
}
DefaultLogFormatter - default log formatter
type Formatter ¶
type Formatter interface {
Format(log *Logger, level Level, msg interface{}, time time.Time) error
}
Formatter interface
type JSONFormatter ¶
type JSONFormatter struct { Level string `json:"level,omitempty"` Time string `json:"time,omitempty"` Message interface{} `json:"message,omitempty"` Fields Fields `json:"fields,omitempty"` }
JSONFormatter to format the log into json format.
type JSONLogFormatter ¶
type JSONLogFormatter struct {
// contains filtered or unexported fields
}
JSONLogFormatter - default log formatter
type Level ¶
type Level int
Level of severity.
const ( // DebugLevel - Detailed debug information. DebugLevel Level = iota // InfoLevel - Interesting events. Examples: User logs in, SQL logs. InfoLevel // WarnLevel - Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong. WarnLevel // ErrorLevel - Runtime errors that do not require immediate action but should typically be logged and monitored. ErrorLevel // FatalLevel - Logs and then calls `os.Exit(1)`. FatalLevel // PanicLevel - highest level of severity PanicLevel )
type Logger ¶
Logger - kira logger.
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug calls log to print to the logger.
func (*Logger) Debugf ¶
Debugf calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Error ¶
func (l *Logger) Error(v ...interface{})
Error calls log to print to the logger.
func (*Logger) Errorf ¶
Errorf calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Fatal ¶
func (l *Logger) Fatal(v ...interface{})
Fatal calls log to print to the logger.
func (*Logger) Fatalf ¶
Fatalf calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Info ¶
func (l *Logger) Info(v ...interface{})
Info calls log to print to the logger.
func (*Logger) Infof ¶
Infof calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Panic ¶
func (l *Logger) Panic(v ...interface{})
Panic calls log to print to the logger.
func (*Logger) Panicf ¶
Panicf calls l.log to print to the logger. Arguments are handled in the manner of fmt.Printf.
func (*Logger) SetFormatter ¶
SetFormatter sets the Formatter for the logger.
func (*Logger) Warn ¶
func (l *Logger) Warn(v ...interface{})
Warn calls log to print to the logger.