Documentation ¶
Index ¶
- Variables
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Warning(v ...interface{})
- func Warningf(format string, v ...interface{})
- func WithLogger(ctx context.Context, logger *Logger) context.Context
- type Fields
- type Formatter
- type Level
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) GetLevel() Level
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) SetFallback(logger *Logger)
- func (l *Logger) SetOutput(out io.Writer)
- func (l *Logger) Warning(v ...interface{})
- func (l *Logger) Warningf(format string, v ...interface{})
- func (l *Logger) WithDepth(depth int) *Logger
- func (l *Logger) WithField(key string, value interface{}) *Logger
- func (l *Logger) WithFields(fields Fields) *Logger
- type Record
- type TextFormatter
Constants ¶
This section is empty.
Variables ¶
var ( // G shortcut to get logger from the context G = GetLogger // L the default logger L = DefaultLogger() )
Functions ¶
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides a struct with fields that describe the details of logger.
func DefaultLogger ¶
func DefaultLogger() *Logger
DefaultLogger returns the default logger within the pkg, i.e. the one used in log.Infof....
func GetLogger ¶
GetLogger retrieves the current logger from the context. If no logger is available, the default logger is returned.
func (*Logger) SetFallback ¶
SetFallback enable fallback when error happen
func (*Logger) WithFields ¶
WithFields returns cloned logger which fields merged with the new fields
type Record ¶
type Record struct { Time time.Time // time when the log produced Msg string // content of the log Line string // in which file and line that the log produced Lvl Level // level of the log }
Record holds information about log
type TextFormatter ¶
type TextFormatter struct {
// contains filtered or unexported fields
}
TextFormatter represents a kind of formatter that formats the logs as plain text
func NewTextFormatter ¶
func NewTextFormatter() *TextFormatter
NewTextFormatter returns a TextFormatter, the format of time is time.RFC3339
func (*TextFormatter) Format ¶
func (t *TextFormatter) Format(r *Record) (b []byte, err error)
Format formats the logs as "time [level] line message"
func (*TextFormatter) SetTimeFormat ¶
func (t *TextFormatter) SetTimeFormat(fmt string)
SetTimeFormat sets time format of TextFormatter if the parameter fmt is not null