package logger // LogLevel 日志级别类型 type LogLevel string const ( DebugLevel LogLevel = "debug" InfoLevel LogLevel = "info" WarnLevel LogLevel = "warn" ErrorLevel LogLevel = "error" ) // Options 日志配置选项 type Options struct { Level LogLevel // 日志级别 Format string // 输出格式: json, console OutputPath string // 输出路径: 文件路径,空则输出到stdout MaxSize int // 日志文件最大大小(MB) MaxBackups int // 保留的旧日志文件最大数量 MaxAge int // 保留旧日志文件的最大天数 Compress bool // 是否压缩归档的日志文件 Caller bool // 是否显示调用者信息 } // DefaultOptions 默认配置 func DefaultOptions() *Options { return &Options{ Level: InfoLevel, Format: "console", OutputPath: "", MaxSize: 100, MaxBackups: 7, MaxAge: 30, Compress: true, Caller: true, } }