Files
doc_ai_backed/pkg/log/log_config.go
2025-12-10 23:17:24 +08:00

31 lines
844 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package log
var (
maxSize = 100 // MB
outputPath = "/app/logs/app.log"
)
type LogConfig struct {
AppName string `yaml:"appName"` // 应用名称
Level string `yaml:"level"` // debug, info, warn, error
Format string `yaml:"format"` // json, console
OutputPath string `yaml:"outputPath"` // 日志文件路径
MaxSize int `yaml:"maxSize"` // 单个日志文件最大尺寸单位MB
MaxAge int `yaml:"maxAge"` // 日志保留天数
MaxBackups int `yaml:"maxBackups"` // 保留的旧日志文件最大数量
Compress bool `yaml:"compress"` // 是否压缩旧日志
}
func DefaultLogConfig() *LogConfig {
return &LogConfig{
Level: "info",
Format: "json",
OutputPath: outputPath,
MaxSize: maxSize,
MaxAge: 7,
MaxBackups: 3,
Compress: true,
}
}