Documentation
¶
Overview ¶
Package log adds log levels to the built in log package.
Index ¶
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Debugln(v ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Errorln(v ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Infoln(v ...interface{})
- func JSON(v interface{}) string
- func JSONIndent(v interface{}) string
- func SetLevel(level Level)
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- func Warnln(v ...interface{})
- type Level
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Debugln(v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Errorln(v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Fatalln(v ...interface{})
- func (l *Logger) For(level Level) *log.Logger
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Infoln(v ...interface{})
- func (l *Logger) IsEnabled(level Level) bool
- func (l *Logger) Level() Level
- func (l *Logger) Panic(v ...interface{})
- func (l *Logger) Panicf(format string, v ...interface{})
- func (l *Logger) Panicln(v ...interface{})
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(format string, v ...interface{})
- func (l *Logger) Println(v ...interface{})
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- func (l *Logger) Warnln(v ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf calls Debugf(format, v...) on the default Logger
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf calls Errorf(format, v...) on the default Logger
func Infof ¶
func Infof(format string, v ...interface{})
Infof calls Infof(format, v...) on the default Logger
func JSON ¶
func JSON(v interface{}) string
JSON returns v marshalled into JSON. If an error occurs, an error message is returned instead. It can be used to quickly add a JSON object into a log message.
func JSONIndent ¶
func JSONIndent(v interface{}) string
JSONIndent returns v marshalled into JSON, with indentation. If an error occurs, an error message is returned instead. It can be used to quickly add a JSON object into a log message.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger wraps multiple loggers (one per log level). Individual loggers may be enabled or disabled depending on the current level (which can be set using the SetLevel function). Messages logged to a disabled level will be discarded.
func New ¶
New returns a new Logger which outputs enabled levels to out. level allows to set the initial enabled level.
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug is equivalent to l.For(LevelDebug).Print(v...)
func (*Logger) Debugln ¶
func (l *Logger) Debugln(v ...interface{})
Debugln is equivalent to l.For(LevelDebug).Println(v...)
func (*Logger) Error ¶
func (l *Logger) Error(v ...interface{})
Error is equivalent to l.For(LevelError).Print(v...)
func (*Logger) Errorln ¶
func (l *Logger) Errorln(v ...interface{})
Errorln is equivalent to l.For(LevelError).Println(v...)
func (*Logger) Fatal ¶
func (l *Logger) Fatal(v ...interface{})
Fatal is equivalent to l.For(LevelError).Fatal(v...) Note that the program will exit even if the Error level is diabled.
func (*Logger) Fatalf ¶
Fatalf is equivalent to l.For(LevelError).Fatalf(format, v...) Note that the program will exit even if the Error level is diabled.
func (*Logger) Fatalln ¶
func (l *Logger) Fatalln(v ...interface{})
Fatalln is equivalent to l.For(LevelError).Fatalln(v...) Note that the program will exit even if the Error level is diabled.
func (*Logger) Info ¶
func (l *Logger) Info(v ...interface{})
Info is equivalent to l.For(LevelInfo).Print(v...)
func (*Logger) Infoln ¶
func (l *Logger) Infoln(v ...interface{})
Infoln is equivalent to l.For(LevelInfo).Println(v...)
func (*Logger) Panic ¶
func (l *Logger) Panic(v ...interface{})
Panic is equivalent to l.For(LevelError).Panic(v...) Note that panic() will be called even if the Error level is diabled.
func (*Logger) Panicf ¶
Panicf is equivalent to l.For(LevelError).Panicf(format, v...) Note that panic() will be called even if the Error level is diabled.
func (*Logger) Panicln ¶
func (l *Logger) Panicln(v ...interface{})
Panicln is equivalent to l.For(LevelError).Panicln(v...) Note that panic() will be called even if the Error level is diabled.
func (*Logger) Println ¶
func (l *Logger) Println(v ...interface{})
Println is equivalent to l.Infoln(v...)
func (*Logger) SetLevel ¶
SetLevel changes the minimal enabled log level. All loggers below level are disabled, other loggers are enabled.
func (*Logger) Warn ¶
func (l *Logger) Warn(v ...interface{})
Warn is equivalent to l.For(LevelWarn).Print(v...)