Documentation
¶
Index ¶
- func Auto2Field(data ...any) []zap.Field
- type Config
- type LogConfig
- type Logger
- func (l *Logger) Debug(ctx context.Context, msg string, data ...any)
- func (l *Logger) Error(ctx context.Context, msg string, data ...any)
- func (l *Logger) Info(ctx context.Context, msg string, data ...any)
- func (l *Logger) LogMode(level logger.LogLevel) logger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *Logger) Warn(ctx context.Context, msg string, data ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
ConsoleSeparator string `json:"console_separator" yaml:"console_separator" ini:"console_separator"` // 控制台分隔符
LogFormat string `json:"log_format" yaml:"log_format" ini:"log_format"` // 日志格式 默认普通控制台格式,支持json格式
LogLevel string `json:"log_level" yaml:"log_level" ini:"log_level"`
LogLevelConfigs map[string]LogConfig `json:"log_level_configs" yaml:"log_level_configs" ini:"log_level_configs"` // key is log level, value is its configuration
}
Config holds the application configuration.
type LogConfig ¶
type LogConfig struct {
FileName string `json:"file_name" yaml:"file_name" int:"file_name"` // 日志文件名称
FilePath string `json:"file_path" yaml:"file_path" int:"file_path"` // 日志路径
MaxSize int `json:"max_size" yaml:"max_size" int:"max_size"` // 文件最大容量 单位MB
MaxBackups int `json:"max_backups" yaml:"max_backups" int:"max_backups"` // 文件最多数量
MaxAge int `json:"max_age" yaml:"max_age" int:"max_age"` // 日志保留最大时长 单位天,0为不限制
Compress bool `json:"compress" yaml:"compress" int:"compress"` // 是否压缩
ToStdout bool `json:"to_stdout" yaml:"to_stdout" ini:"to_stdout"` // 是否输出到标准输出
}
LogConfig defines the configuration for each log level.
Click to show internal directories.
Click to hide internal directories.