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 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 WithLevelStr(level zapcore.Level) Option
- func WithNoCaller(noCaller bool) Option
- func WithText(text bool) Option
- func WithTimeLayout(timeLayout string) Option
- func WithWarnLevel() Option
Constants ¶
View Source
const ( // DefaultLevel the default log level DefaultLevel = zapcore.InfoLevel // DefaultTimeLayout the default time layout; DefaultTimeLayout = time.RFC3339 )
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 LogModule ¶
type LogModule struct { File *LogAppenderCfg `yaml:"file"` // for file appender Console *LogAppenderCfg `yaml:"console"` // for console appender Appenders []LogAppenderCfg `yaml:"appenders"` // 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 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 WithLevelStr ¶
WithDebugLevel 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.