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 KitLogger
- type Level
- type LogConfig
- type Logger
- type MessageLogger
- type MoveFileType
- type Option
- func Caller() Option
- func CallerSkip(cs int) Option
- func EncoderConfig(encoder zapcore.EncoderConfig) Option
- func Encoding(encoding string) Option
- func LogFileOption(opts ...FileOption) Option
- func LogFileOptions(fos *FileOptions) Option
- func LogLevel(lvl Level) Option
- func ShowXormSQL(show ...bool) Option
- func StackTrace() Option
- type XormLogger
- type ZapLogger
- func (p *ZapLogger) Debug(kvs ...interface{})
- func (p *ZapLogger) DebugM(msg string, kvs ...interface{})
- func (p *ZapLogger) Debugf(msg string, kvs ...interface{})
- func (p *ZapLogger) Error(kvs ...interface{})
- func (p *ZapLogger) ErrorM(msg string, kvs ...interface{})
- func (p *ZapLogger) Errorf(msg string, kvs ...interface{})
- func (p *ZapLogger) Fatal(kvs ...interface{})
- func (p *ZapLogger) FatalM(msg string, kvs ...interface{})
- func (p *ZapLogger) Fatalf(msg string, kvs ...interface{})
- func (p *ZapLogger) GetZapLogger() *zap.Logger
- func (p *ZapLogger) Info(kvs ...interface{})
- func (p *ZapLogger) InfoM(msg string, kvs ...interface{})
- func (p *ZapLogger) Infof(msg string, kvs ...interface{})
- func (p *ZapLogger) IsShowSQL() bool
- func (p *ZapLogger) Level() log.LogLevel
- func (p *ZapLogger) Log(kvs ...interface{}) error
- func (p *ZapLogger) Panic(kvs ...interface{})
- func (p *ZapLogger) PanicM(msg string, kvs ...interface{})
- func (p *ZapLogger) Panicf(msg string, kvs ...interface{})
- func (p *ZapLogger) SetLevel(l log.LogLevel)
- func (p *ZapLogger) ShowSQL(show ...bool)
- func (p *ZapLogger) Warn(kvs ...interface{})
- func (p *ZapLogger) WarnM(msg string, kvs ...interface{})
- func (p *ZapLogger) Warnf(msg string, kvs ...interface{})
- func (p *ZapLogger) With(kvs ...interface{}) Logger
- func (p *ZapLogger) Writer() io.Writer
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 ( DefaultEncoderConfig = zapcore.EncoderConfig{ TimeKey: "ts", LevelKey: "level", NameKey: "log", CallerKey: "caller", MessageKey: "msg", StacktraceKey: "stacktrace", LineEnding: zapcore.DefaultLineEnding, EncodeLevel: zapcore.LowercaseLevelEncoder, EncodeTime: zapcore.RFC3339NanoTimeEncoder, EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, } )
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 ¶
func NewFileLogger(opts ...FileOption) (*fileLogger, error)
NewFileLogger 标准窗体的输出对象
func NewFileLoggerWithOptions ¶
func NewFileLoggerWithOptions(opts FileOptions) (*fileLogger, error)
NewFileLoggerWithOptions 标准窗体的输出对象
Types ¶
type FileOption ¶
type FileOption func(*FileOptions)
FileOption 操作配置函数
func OptionMoveFileType ¶
func OptionMoveFileType(typ MoveFileType) FileOption
OptionMoveFileType 设置移动文件的类型
type FileOptions ¶
type FileOptions struct { Filename string `yaml:"filename" json:"filename"` FileExt string `yaml:"file_ext" json:"file_ext"` FileBasename string `yaml:"-" json:"-"` FileDir string `yaml:"-" json:"-"` StdPrinters types.Strings `yaml:"std_printers" json:"std_printers"` Separator string `yaml:"separator" json:"separator"` MaxLength int64 `yaml:"max_length" json:"max_length"` MoveFileType MoveFileType `yaml:"move_file_type" json:"move_file_type"` // 最大保留日志个数,如果为0则全部保留 MaxBackups int `yaml:"max_backups" json:"max_backups"` }
FileOptions file options
func (*FileOptions) Check ¶
func (p *FileOptions) Check() error
func (*FileOptions) ParseFlags ¶
func (p *FileOptions) ParseFlags(f *flag.FlagSet)
func (*FileOptions) ParseFlagsWithPrefix ¶
func (p *FileOptions) ParseFlagsWithPrefix(prefix string, f *flag.FlagSet)
ParseFlagsWithPrefix adds the flags required to config this to the given FlagSet.
type Level ¶
type Level int32
Level log level
func (*Level) ToZapLevel ¶
ToZapLevel convert level into zap level
type LogConfig ¶
type LogConfig struct { Level Level `yaml:"level" json:"level"` Encoding string `yaml:"encoding" json:"encoding"` // json | console, default console CallerSkip int `yaml:"caller_skip" json:"caller_skip"` Caller bool `yaml:"caller" json:"caller"` StackTrace bool `yaml:"stack_trace" json:"stack_trace"` FileOptions FileOptions `yaml:",inline" json:",inline"` EncoderConfig zapcore.EncoderConfig `yaml:",inline,omitempty" json:",inline,omitempty"` ShowXormSQL bool `yaml:"show_xorm_sql" json:"show_xorm_sql"` // contains filtered or unexported fields }
func (*LogConfig) ParseFlags ¶
func (*LogConfig) ParseFlagsWithPrefix ¶
ParseFlagsWithPrefix adds the flags required to config this to the given FlagSet.
func (*LogConfig) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface for LogConfig.
type Logger ¶
type Logger interface { KitLogger XormLogger MessageLogger With(kvs ...interface{}) Logger Writer() io.Writer }
Logger 日志对象
func NewWithZapLogger ¶
type MessageLogger ¶
type MoveFileType ¶
type MoveFileType int
MoveFileType move file type
const ( MoveFileTypeNothing MoveFileType = iota // 不移动 MoveFileTypePerMinite // 按分钟移动 MoveFileTypeHourly // 按小时移动 MoveFileTypeDaily // 按天移动 )
MoveFileTypes
type XormLogger ¶
type ZapLogger ¶
type ZapLogger struct {
// contains filtered or unexported fields
}
func NewLoggerWithConfig ¶
func (*ZapLogger) GetZapLogger ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.