Documentation
¶
Index ¶
- type ConsoleStream
- type FileRotation
- type Level
- type LocalFormat
- type LogPair
- type Logger
- func (l Logger) CanOutput(level Level) bool
- func (l Logger) Debug(subject string, pairs ...LogPair)
- func (l Logger) Error(subject string, pairs ...LogPair)
- func (l Logger) Info(subject string, pairs ...LogPair)
- func (l Logger) IsEmpty() bool
- func (l *Logger) SetLevel(level Level)
- func (l Logger) Warn(subject string, pairs ...LogPair)
- func (l Logger) WithTrace(trace Trace) Logger
- func (l Logger) WithTraceLogs(pairs ...LogPair) Logger
- func (l Logger) WrapContext(ctx context.Context) context.Context
- type MessageFormat
- type Output
- type TimeFormat
- type Trace
- type TraceID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsoleStream ¶
type ConsoleStream string
const ( ConsoleStreamStdout ConsoleStream = "stdout" ConsoleStreamStderr ConsoleStream = "stderr" )
func MakeConsoleStream ¶
func MakeConsoleStream(raw string) ConsoleStream
type FileRotation ¶
type FileRotation struct { MaxSize int Compress bool MaxAge int MaxBackups int LocalTime bool // RotateOnTime enables log rotation based on time. RotateOnTime bool // RotatePeriod is the period for log rotation. // Supports daily(d), hourly(h), minute(m) and second(s). RotatePeriod string // RotateAfter sets a value for time based rotation. // Log file rotates every RotateAfter * RotatePeriod. RotateAfter int }
Rotation stores configs for the log rotation. See more in https://github.com/natefinch/lumberjack/tree/v2.0
type LocalFormat ¶
type LocalFormat struct { Format MessageFormat MessageKey string TimeKey string LevelKey string NameKey string CallerKey string // 时间格式 TimeFormat TimeFormat // 默认为TimeFormatRFC3339 }
func MakeLocalFormat ¶
func MakeLocalFormat(msg MessageFormat) LocalFormat
type LogPair ¶
type LogPair struct {
// contains filtered or unexported fields
}
func ConvertStrMapToLogPairs ¶
func JsonString ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewLoggerWithTrace ¶
func WithContext ¶
func (Logger) WithTraceLogs ¶
type MessageFormat ¶
type MessageFormat string
const ( MessageFormatJSON MessageFormat = "json" MessageFormatText MessageFormat = "text" )
func MakeMessageFormat ¶
func MakeMessageFormat(raw string) MessageFormat
MakeMessageFormat would product MessageFormat with raw string. MessageFormatText would be default returning if no matched.
type Output ¶
func MakeConsoleOutput ¶
func MakeConsoleOutput(name string, fmt LocalFormat, level Level, stream ConsoleStream) Output
func MakeFileOutput ¶
func MakeFileOutput(name string, fmt LocalFormat, level Level, location string, rotation FileRotation) Output
type TimeFormat ¶
type TimeFormat string
const ( TimeFormatRFC3339 TimeFormat = "rfc3339" TimeFormatISO8601 TimeFormat = "iso8601" TimeFormatSeconds TimeFormat = "seconds" TimeFormatMillis TimeFormat = "millis" TimeFormatNanos TimeFormat = "nanos" )
func MakeTimeFormat ¶
func MakeTimeFormat(raw string) TimeFormat
Click to show internal directories.
Click to hide internal directories.