|
@@ -65,9 +65,13 @@ func NewServiceLog(conf *viper.Viper, serviceType ServiceType) *Logger {
|
|
|
// 使用Task日志路径
|
|
|
logPath = conf.GetString("log.task_log_file")
|
|
|
logPath = fmt.Sprintf(logPath, currentDate) // 替换日期占位符
|
|
|
- } else {
|
|
|
- // 如果未配置专用日志路径,则使用旧配置
|
|
|
+ } else if conf.IsSet("log.log_file_name") {
|
|
|
+ // 即使使用旧配置,也添加日期分区
|
|
|
logPath = conf.GetString("log.log_file_name")
|
|
|
+ // 截取扩展名前的部分,添加日期,然后加上扩展名
|
|
|
+ ext := filepath.Ext(logPath)
|
|
|
+ base := logPath[:len(logPath)-len(ext)]
|
|
|
+ logPath = fmt.Sprintf("%s-%s%s", base, currentDate, ext)
|
|
|
}
|
|
|
|
|
|
// 处理相对路径,兼容不同的工作目录
|