Documentation ¶
Index ¶
- type ConsoleStream
- type FileRotation
- type FluentOutput
- func (o *FluentOutput) Init()
- func (o *FluentOutput) Level() Level
- func (o *FluentOutput) Log(l Level, msg string, argPairs []interface{})
- func (o *FluentOutput) LogFormatted(l Level, format string, args []interface{})
- func (o *FluentOutput) LogMap(l Level, msg string, values map[string]interface{})
- func (o *FluentOutput) LogPlainMessage(l Level, args []interface{})
- type Level
- type LocalFormat
- type Logger
- func (l *Logger) Debug(msg string, args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Debugm(msg string, values map[string]interface{})
- func (l *Logger) Error(msg string, args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Errorm(msg string, values map[string]interface{})
- func (l *Logger) Fatal(msg string, args ...interface{})
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Fatalm(msg string, values map[string]interface{})
- func (l *Logger) Info(msg string, args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Infom(msg string, values map[string]interface{})
- func (l *Logger) Log(level Level, msg string, argPairs ...interface{})
- func (l *Logger) LogFormatted(level Level, format string, args ...interface{})
- func (l *Logger) LogMap(level Level, msg string, values map[string]interface{})
- func (l *Logger) LogPlainMessage(level Level, args ...interface{})
- func (l *Logger) Warn(msg string, args ...interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) Warnm(msg string, values map[string]interface{})
- type MessageFormat
- type Output
- type TimeFormat
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 FluentOutput ¶
type FluentOutput struct {
// contains filtered or unexported fields
}
func (*FluentOutput) Init ¶
func (o *FluentOutput) Init()
func (*FluentOutput) Level ¶
func (o *FluentOutput) Level() Level
func (*FluentOutput) Log ¶
func (o *FluentOutput) Log(l Level, msg string, argPairs []interface{})
func (*FluentOutput) LogFormatted ¶
func (o *FluentOutput) LogFormatted(l Level, format string, args []interface{})
func (*FluentOutput) LogMap ¶
func (o *FluentOutput) LogMap(l Level, msg string, values map[string]interface{})
func (*FluentOutput) LogPlainMessage ¶
func (o *FluentOutput) LogPlainMessage(l Level, args []interface{})
type LocalFormat ¶
type LocalFormat struct { Format MessageFormat MessageKey string // 默认为M TimeKey string // 默认为T LevelKey string // 默认为L NameKey string // 默认为N CallerKey string // 默认为C // 时间格式 TimeFormat TimeFormat // 默认为TimeFormatISO8601 }
func MakeLocalFormat ¶
func MakeLocalFormat(msg MessageFormat) LocalFormat
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) Log ¶
发送可转换为key-value结构的消息. - Parameters:
- argPairs: 键值对列表,键或值为nil的将不被记录
console: 直接发给zap.w处理 fluent: 拼成map {"message": msg, "data": {arg0: arg1, arg2: arg3, ...}}
func (*Logger) LogFormatted ¶
发送格式化后的简单消息,逻辑与LogPlainMessage基本相同
func (*Logger) LogPlainMessage ¶
发送简单消息 console: 直接发给zap处理 fluent: 将所有args串接起来调用fluent output的LogMap(level, joinedString, nil)
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 ¶
type Output interface { Level() Level Log(l Level, msg string, argPairs []interface{}) LogMap(l Level, msg string, values map[string]interface{}) LogPlainMessage(l Level, args []interface{}) LogFormatted(l Level, format string, args []interface{}) }
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 ( 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.