Documentation ¶
Index ¶
- Constants
- Variables
- func NewFileLogger(opts ...FileOption) (*fileLogger, error)
- func NewFileLoggerWithOptions(opts FileOptions) (*fileLogger, error)
- func ToLevelName(lvl Level) string
- type FileOption
- type FileOptions
- type FileSort
- type Level
- type LogConfig
- type Logger
- type MoveFileType
- type Option
- type SimpleLogger
- type ZapLogger
- func (p *ZapLogger) Debug(msg string, kvs ...interface{})
- func (p *ZapLogger) Debugf(msg string, kvs ...interface{})
- func (p *ZapLogger) Error(msg string, kvs ...interface{})
- func (p *ZapLogger) Errorf(msg string, kvs ...interface{})
- func (p *ZapLogger) Fatal(msg string, kvs ...interface{})
- func (p *ZapLogger) Fatalf(msg string, kvs ...interface{})
- func (p *ZapLogger) GetZapLogger() *zap.Logger
- func (p *ZapLogger) Info(msg string, kvs ...interface{})
- func (p *ZapLogger) Infof(msg string, kvs ...interface{})
- func (p *ZapLogger) Log(kvs ...interface{}) error
- func (p *ZapLogger) Panic(msg string, kvs ...interface{})
- func (p *ZapLogger) Panicf(msg string, kvs ...interface{})
- func (p *ZapLogger) Warn(msg string, kvs ...interface{})
- func (p *ZapLogger) Warnf(msg string, kvs ...interface{})
- func (p *ZapLogger) With(kvs ...interface{}) Logger
Constants ¶
View Source
const ( TraceLevel = Level(iota) DebugLevel InfoLevel WarnLevel ErrorLevel PanicLevel FatalLevel LevelNameUnknown = "NULL" LevelNameTrace = "TRAC" LevelNameDebug = "DEBU" LevelNameInfo = "INFO" LevelNameWarn = "WARN" LevelNameError = "ERRO" LevelNamePanic = "PANC" LevelNameFatal = "CRIT" )
define levels
Variables ¶
View Source
var LevelColors = map[Level]string{ TraceLevel: levelColorDebug, DebugLevel: levelColorDebug, InfoLevel: levelColorInfo, WarnLevel: levelColorWarn, ErrorLevel: levelColorError, PanicLevel: levelColorPanic, FatalLevel: levelColorFatal, }
LevelColors printer's color
Functions ¶
func NewFileLogger ¶ added in v0.21.2
func NewFileLogger(opts ...FileOption) (*fileLogger, error)
NewFileLogger 标准窗体的输出对象
func NewFileLoggerWithOptions ¶ added in v0.21.9
func NewFileLoggerWithOptions(opts FileOptions) (*fileLogger, error)
NewFileLogger 标准窗体的输出对象
Types ¶
type FileOption ¶ added in v0.21.2
type FileOption func(*FileOptions)
FileOption 操作配置函数
func OptionFilename ¶ added in v0.21.9
func OptionFilename(name string) FileOption
OptionFilename 设置文件名
func OptionMaxBackups ¶ added in v0.21.9
func OptionMaxBackups(num int) FileOption
OptionMaxBackups 文件最大数量
func OptionMaxLength ¶ added in v0.21.9
func OptionMaxLength(length int64) FileOption
OptionMaxLength 设置最大文件大小
func OptionMoveFileType ¶ added in v0.21.9
func OptionMoveFileType(typ MoveFileType) FileOption
OptionMoveFileType 设置移动文件的类型
func OptionSeparator ¶ added in v0.21.9
func OptionSeparator(separator string) FileOption
OptionSeparator 设置打印分隔符
func OptionStdPrinters ¶ added in v0.21.9
func OptionStdPrinters(ps []string) FileOption
OptionStdPrinters 设置移动文件的类型
type FileOptions ¶ added in v0.21.2
type FileOptions struct { Filename string `yaml:"filename"` StdPrinters []string `yaml:"std_printers"` Separator string `yaml:"separator"` MaxLength int64 `yaml:"max_length"` MoveFileType MoveFileType `yaml:"move_file_type"` // 最大保留日志个数,如果为0则全部保留 MaxBackups int `yaml:"max_backups"` }
FileOptions file options
func (*FileOptions) Check ¶ added in v0.21.9
func (p *FileOptions) Check() error
type Level ¶
type Level int32
Level log level
func (*Level) ToZapLevel ¶ added in v0.21.9
ToZapLevel convert level into zap level
type LogConfig ¶ added in v0.21.9
type LogConfig struct { Level Level `yaml:"level"` Encoding string `yaml:"encoding,omitempty"` // json | console, default console CallerSkip int `yaml:"caller_skip"` StackTrace bool `yaml:"stack_trace"` Caller bool `yaml:"caller"` EncoderConfig *zapcore.EncoderConfig `yaml:",inline,omitempty"` FileOptions FileOptions `yaml:",inline"` }
type Logger ¶
type Logger interface { SimpleLogger With(kvs ...interface{}) Logger Debug(msg string, kvs ...interface{}) // Debug(msg string, fields ...Field) Debugf(msg string, kvs ...interface{}) Info(msg string, kvs ...interface{}) // Info(msg string, fields ...Field) Infof(msg string, kvs ...interface{}) Warn(msg string, kvs ...interface{}) // Warn(msg string, fields ...Field) Warnf(msg string, kvs ...interface{}) Error(msg string, kvs ...interface{}) // Error(msg string, fields ...Field) Errorf(msg string, kvs ...interface{}) Panic(msg string, kvs ...interface{}) Panicf(msg string, kvs ...interface{}) // Panic(msg string, fields ...Field) Fatal(msg string, kvs ...interface{}) Fatalf(msg string, kvs ...interface{}) // Fatal(msg string, fields ...Field) }
Logger 日志对象
func NewWithZapLogger ¶ added in v0.21.15
type MoveFileType ¶
type MoveFileType int
MoveFileType move file type
const ( MoveFileTypeNothing MoveFileType = iota // 不移动 MoveFileTypePerMinite // 按分钟移动 MoveFileTypeHourly // 按小时移动 MoveFileTypeDaily // 按天移动 )
MoveFileTypes
type Option ¶ added in v0.21.1
type Option func(*LogConfig)
func EncoderConfig ¶ added in v0.21.11
func EncoderConfig(encoder *zapcore.EncoderConfig) Option
EncoderConfig 设置等级
func LogFileOption ¶ added in v0.21.9
func LogFileOption(opts ...FileOption) Option
LogFileOption 设置等级
func LogFileOptions ¶ added in v0.21.9
func LogFileOptions(fos *FileOptions) Option
LogFileOptions 设置等级
type SimpleLogger ¶ added in v0.21.10
type SimpleLogger interface {
Log(keyvals ...interface{}) error
}
func NewZapSugarLogger ¶ added in v0.21.10
NewZapSugarLogger returns a Go kit log.Logger that sends log events to a zap.Logger.
type ZapLogger ¶ added in v0.21.9
type ZapLogger struct {
// contains filtered or unexported fields
}
func (*ZapLogger) GetZapLogger ¶ added in v0.21.11
Source Files ¶
Click to show internal directories.
Click to hide internal directories.