Documentation
¶
Index ¶
Constants ¶
View Source
const ( HolderLevel = "${level}" DefaultFilePattern = "j-%Y-%m-%d.log" )
Variables ¶
View Source
var Zap = new(_zap)
Functions ¶
This section is empty.
Types ¶
type KeyLogConfig ¶
type LogConfig ¶
type LogConfig struct { // 级别 Level string `mapstructure:"level,omitempty" json:"level,omitempty" yaml:"level,omitempty"` // 日志文件夹 Dir string `mapstructure:"dir,omitempty" json:"dir,omitempty" yaml:"dir,omitempty" toml:"dir,omitempty"` // 日志文件路径(模式),可以用多级路径,拼接在 Dir 后面。 // 可用时间格式、事件格式,如 %Y-%m-%d/${level}.log 表示 按日期和级别分割 FilePattern string `mapstructure:"filePattern,omitempty" json:"filePattern,omitempty" yaml:"filePattern,omitempty" toml:"filePattern,omitempty"` // 日志留存时间(天) MaxAge int `mapstructure:"maxAge,omitempty" json:"maxAge,omitempty" yaml:"maxAge,omitempty" toml:"maxAge,omitempty"` // 输出格式 console(默认) 或者 json Format string `mapstructure:"format,omitempty" json:"format,omitempty" yaml:"format,omitempty" toml:"format,omitempty"` // 编码级,可用值为: // color // capital // capitalColor EncodeLevel string `mapstructure:"encodeLevel,omitempty" json:"encodeLevel,omitempty" yaml:"encodeLevel,omitempty" toml:"encodeLevel,omitempty"` // 自定义特殊字段的 key,主要是用在 json 格式中 LogKey *KeyLogConfig `mapstructure:"logKey,omitempty" json:"logKey,omitempty" yaml:"logKey,omitempty" toml:"logKey,omitempty"` // 显示行号 ShowLine bool `mapstructure:"showLine,omitempty" json:"showLine,omitempty" yaml:"showLine,omitempty" toml:"showLine,omitempty"` // 输出到文件同时输出到控制台 AppendConsole bool `` /* 131-byte string literal not displayed */ }
func (*LogConfig) GetLogPath ¶
GetLogPath 获取日志文件路径,如果没有配置,则返回空。如果只配置了目录,则按日期拆分
func (*LogConfig) ISFileSplitByEvent ¶
ISFileSplitByEvent 是否按事件分割文件
func (*LogConfig) TransportLevel ¶
TransportLevel 获取日志级别,默认是 info
func (*LogConfig) ZapEncodeLevel ¶
func (c *LogConfig) ZapEncodeLevel() zapcore.LevelEncoder
ZapEncodeLevel "color": 小写编码器带颜色 "capital": 大写编码器 "capitalColor": 大写编码器带颜色 小写编码器(默认)
Click to show internal directories.
Click to hide internal directories.