Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDisabled ¶
IsDisabled 检查指定的 logger 是否被禁用 支持前缀匹配,如禁用 "grpc" 会同时禁用 "grpc", "grpc.server", "grpc.client" 等
func SetDisabledLoggers ¶
func SetDisabledLoggers(names []string)
SetDisabledLoggers 设置要禁用的 logger 名称列表 这些 logger 的日志输出将被 EnableChecker 过滤掉
Types ¶
type Config ¶
type Config struct {
// Level 日志级别: trace, debug, info, warn, error, fatal, panic
Level string `yaml:"level"`
// AsJson 终端是否以 JSON 格式输出
AsJson bool `yaml:"as_json"`
// DisableLoggers 要禁用日志输出的 logger 名称列表
// 支持前缀匹配,如 "grpc" 会禁用 "grpc", "grpc.server" 等
DisableLoggers []string `yaml:"disable_loggers"`
// Filters expr 表达式过滤器列表,多个表达式以 && 连接
Filters []string `yaml:"filters"`
// File 文件输出配置,为空则不输出到文件
File *FileConfig `yaml:"file"`
}
Config 日志配置
func (*Config) GetLogFilePath ¶
GetLogFilePath 获取日志文件路径(用于 loggerdebug 读取)
type FileConfig ¶
type FileConfig struct {
// Enabled 是否启用文件输出
Enabled bool `yaml:"enabled"`
// Path 日志文件路径
Path string `yaml:"path"`
// MaxSize 单个日志文件最大大小(MB)
MaxSize int `yaml:"max_size"`
// MaxBackups 保留的旧日志文件最大数量
MaxBackups int `yaml:"max_backups"`
// MaxAge 保留旧日志文件的最大天数
MaxAge int `yaml:"max_age"`
// Compress 是否压缩旧日志文件
Compress bool `yaml:"compress"`
}
FileConfig 文件输出配置
type LogConfigLoader ¶
type LogConfigLoader struct {
Log *Config `yaml:"logger"`
}
LogConfigLoader 配置加载器
Click to show internal directories.
Click to hide internal directories.