fix: improve logger initialization and reduce cache TTL
This commit is contained in:
@@ -25,15 +25,16 @@ func InitLogger() {
|
||||
}
|
||||
}
|
||||
consoleH := handler.NewConsoleHandler(logLevels)
|
||||
fileH, err := handler.NewTimeRotateFile(
|
||||
logFilePath,
|
||||
rotatefile.EveryDay,
|
||||
handler.WithLogLevels(slog.AllLevels),
|
||||
handler.WithBackupNum(logBackupNum),
|
||||
handler.WithBuffSize(0),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
Log.AddHandler(consoleH)
|
||||
if logFilePath != "" && logBackupNum > 0 {
|
||||
fileH, err := handler.NewTimeRotateFile(
|
||||
logFilePath,
|
||||
rotatefile.EveryDay,
|
||||
handler.WithLogLevels(slog.AllLevels),
|
||||
handler.WithBackupNum(logBackupNum))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
Log.AddHandler(fileH)
|
||||
}
|
||||
Log.AddHandlers(consoleH, fileH)
|
||||
}
|
||||
|
||||
@@ -90,11 +90,9 @@ func Init() error {
|
||||
viper.SetDefault("telegram.rpc_retry", 5)
|
||||
|
||||
viper.SetDefault("temp.base_path", "cache/")
|
||||
viper.SetDefault("temp.cache_ttl", 3600)
|
||||
viper.SetDefault("temp.cache_ttl", 30)
|
||||
|
||||
viper.SetDefault("log.level", "INFO")
|
||||
viper.SetDefault("log.file", "logs/saveany.log")
|
||||
viper.SetDefault("log.backup_count", 7)
|
||||
|
||||
viper.SetDefault("db.path", "data/saveany.db")
|
||||
viper.SetDefault("db.session", "data/session.db")
|
||||
|
||||
Reference in New Issue
Block a user