Documentation ¶
Index ¶
- Constants
- func NewJSONLogger(opts ...Option) (*zap.Logger, error)
- func NewLogger(text bool, opts ...Option) (*zap.Logger, error)
- func NewTextLogger(opts ...Option) (*zap.Logger, error)
- func WrapMeta(err error, metas ...Meta) (fields []zap.Field)
- type LogAppender
- type LogAppenderCfg
- type LogLevel
- type LogModule
- type Meta
- type Option
- func WithConsoleAppender(appender LogAppender) Option
- func WithConsoleDisable(disabled bool) Option
- func WithConsoleLevel(level zapcore.Level) Option
- func WithConsoleLevelInt8(level int8) Option
- func WithConsoleText(text bool) Option
- func WithDebugLevel() Option
- func WithErrorLevel() Option
- func WithField(key, value string) Option
- func WithFileP(file string) Option
- func WithFileRotationP(file string) Option
- func WithInfoLevel() Option
- func WithLevel(level zapcore.Level) Option
- func WithLevelInt8(level int8) Option
- func WithNoCaller(noCaller bool) Option
- func WithText(text bool) Option
- func WithTimeLayout(timeLayout string) Option
- func WithWarnLevel() Option
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func NewJSONLogger ¶
NewJSONLogger return a json-encoder zap logger,
func NewTextLogger ¶
NewTextLogger return a json-encoder zap logger,
Types ¶
type LogAppender ¶
type LogAppender struct {
// contains filtered or unexported fields
}
type LogAppenderCfg ¶
type LogAppenderCfg struct { NoCaller *bool `yaml:"noCaller,omitempty"` // Disabled *bool `yaml:"disabled,omitempty"` // disabled Text *bool `yaml:"text,omitempty"` // json or text format Level *int8 `yaml:"level,omitempty"` // int8 ? zapcore.Level yml格式化输出会输出debug这种字符串,parse然后得不到正确是数值,所以改用int8 Path string `yaml:"path,omitempty"` // file path, for file appender, useless for console }
type LogModule ¶
type LogModule struct { File *LogAppenderCfg `yaml:"file,omitempty"` // for file appender Console *LogAppenderCfg `yaml:"console,omitempty"` // for console appender Appenders []LogAppenderCfg `yaml:"appenders,omitempty"` // other appenders }
func GetDefLogCfg ¶
func InitLogModuleCfg ¶
func InitLogModuleCfg(baseCfg *LogModule, logModuleCfg *LogModule, moduleDefLogFile string) *LogModule
fill default data for log module, otherwise some value will be nil
type Meta ¶
type Meta interface { Key() string Value() interface{} // contains filtered or unexported methods }
Meta key-value
type Option ¶
type Option func(*option)
Option custom setup config
func WithConsoleAppender ¶
func WithConsoleAppender(appender LogAppender) Option
func WithConsoleDisable ¶
WithConsoleDisable write log to os.Stdout or os.Stderr
func WithConsoleLevel ¶
func WithConsoleLevelInt8 ¶ added in v0.0.43
func WithConsoleText ¶
func WithDebugLevel ¶
func WithDebugLevel() Option
WithDebugLevel only greater than 'level' will output
func WithErrorLevel ¶
func WithErrorLevel() Option
WithErrorLevel only greater than 'level' will output
func WithFileRotationP ¶
WithFileRotationP write log to some file with rotation
func WithInfoLevel ¶
func WithInfoLevel() Option
WithInfoLevel only greater than 'level' will output
func WithTimeLayout ¶
WithTimeLayout custom time format
func WithWarnLevel ¶
func WithWarnLevel() Option
WithWarnLevel only greater than 'level' will output
Click to show internal directories.
Click to hide internal directories.