Documentation
¶
Index ¶
- Variables
- func AlarmFatal(msg string, exitCode int)
- func AlarmPanic(msg string)
- func Debug(msg string, keyValues ...any)
- func Error(msg string, keyValues ...any)
- func Fatal(msg string, keyValues ...any)
- func Info(msg string, keyValues ...any)
- func Panic(msg string, keyValues ...any)
- func RegisterLevel(l Level, s string) error
- func SetGlobalLogger(logger *Logger)
- func Warn(msg string, keyValues ...any)
- type Event
- type Formatter
- type Level
- type Logger
- func (l *Logger) Debug(msg string, keyValues ...any)
- func (l *Logger) Error(msg string, keyValues ...any)
- func (l *Logger) Fatal(msg string, keyValues ...any)
- func (l *Logger) Info(msg string, keyValues ...any)
- func (l *Logger) Panic(msg string, keyValues ...any)
- func (l *Logger) SetAlarmFatal(alarmFatal func(msg string, exitCode int))
- func (l *Logger) SetAlarmPanic(alarmPanic func(msg string))
- func (l *Logger) SetCallerSkip(skip int)
- func (l *Logger) SetFields(fields ...func(f Formatter, event *Event) bytes.BufferWriter)
- func (l *Logger) SetFormatter(formatter Formatter)
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) SetWriter(writer io.Writer)
- func (l *Logger) Warn(msg string, keyValues ...any)
- type TextFormatter
- func (f *TextFormatter) FormatCaller(callerSkip int) bytes.BufferWriter
- func (f *TextFormatter) FormatLevel(level Level) bytes.BufferWriter
- func (f *TextFormatter) FormatMsg(msg string, keyValues ...any) bytes.BufferWriter
- func (f *TextFormatter) FormatTime(t time.Time) bytes.BufferWriter
- func (f *TextFormatter) MsgSplit() string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( FieldLevel = func(f Formatter, event *Event) bytes.BufferWriter { return f.FormatLevel(event.Level) } FieldTime = func(f Formatter, event *Event) bytes.BufferWriter { return f.FormatTime(event.Time) } FieldCaller = func(f Formatter, event *Event) bytes.BufferWriter { return f.FormatCaller(event.CallerSkip) } )
View Source
var ErrLevelAlreadyRegistered = errors.New("level already registered")
Functions ¶
func AlarmFatal ¶
func AlarmPanic ¶
func AlarmPanic(msg string)
func RegisterLevel ¶
func SetGlobalLogger ¶
func SetGlobalLogger(logger *Logger)
SetGlobalLogger sets a global logger.
CallerSkip of global logger should be 4 at least. Make sure that you set the correct caller skip.
Types ¶
type Formatter ¶
type Formatter interface {
FormatLevel(level Level) bytes.BufferWriter
FormatTime(t time.Time) bytes.BufferWriter
FormatCaller(callerSkip int) bytes.BufferWriter
FormatMsg(msg string, keyValues ...any) bytes.BufferWriter
MsgSplit() string
}
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) SetAlarmFatal ¶ added in v0.1.1
func (*Logger) SetAlarmPanic ¶ added in v0.1.1
func (*Logger) SetCallerSkip ¶ added in v0.1.1
func (*Logger) SetFields ¶ added in v0.1.1
func (l *Logger) SetFields(fields ...func(f Formatter, event *Event) bytes.BufferWriter)
func (*Logger) SetFormatter ¶ added in v0.1.1
type TextFormatter ¶
type TextFormatter struct{}
func (*TextFormatter) FormatCaller ¶
func (f *TextFormatter) FormatCaller(callerSkip int) bytes.BufferWriter
func (*TextFormatter) FormatLevel ¶
func (f *TextFormatter) FormatLevel(level Level) bytes.BufferWriter
func (*TextFormatter) FormatMsg ¶
func (f *TextFormatter) FormatMsg(msg string, keyValues ...any) bytes.BufferWriter
func (*TextFormatter) FormatTime ¶
func (f *TextFormatter) FormatTime(t time.Time) bytes.BufferWriter
func (*TextFormatter) MsgSplit ¶
func (f *TextFormatter) MsgSplit() string
Click to show internal directories.
Click to hide internal directories.