Commit 5ac82f03 authored by 吴贤德's avatar 吴贤德

中心服务:去掉logrus日志输出,修复合作方媒资元数据推送问题(动态修改推送标志无效问题)

parent 0a94a2f9
package Config package Config
import ( import (
rotatelogs "github.com/lestrrat/go-file-rotatelogs"
"github.com/pkg/errors"
"github.com/rifflock/lfshook"
log "github.com/sirupsen/logrus"
"path"
"time" "time"
) )
// config logrus log to local filesystem, with file rotation // config logrus log to local filesystem, with file rotation
func initLogConfig(logPath string, logFileName string, maxAge time.Duration, rotationTime time.Duration) { func initLogConfig(logPath string, logFileName string, maxAge time.Duration, rotationTime time.Duration) {
baseLogPaht := path.Join(logPath, logFileName) //baseLogPaht := path.Join(logPath, logFileName)
writer, err := rotatelogs.New( //writer, err := rotatelogs.New(
baseLogPaht+".%Y%m%d%H%M", // baseLogPaht+".%Y%m%d%H%M",
rotatelogs.WithLinkName(baseLogPaht), // 生成软链,指向最新日志文件 // rotatelogs.WithLinkName(baseLogPaht), // 生成软链,指向最新日志文件
rotatelogs.WithMaxAge(maxAge), // 文件最大保存时间 // rotatelogs.WithMaxAge(maxAge), // 文件最大保存时间
rotatelogs.WithRotationTime(rotationTime), // 日志切割时间间隔 // rotatelogs.WithRotationTime(rotationTime), // 日志切割时间间隔
) //)
if err != nil { //if err != nil {
log.Errorf("config local file system logger error. %+v", errors.WithStack(err)) // log.Errorf("config local file system logger error. %+v", errors.WithStack(err))
} //}
lfHook := lfshook.NewHook(lfshook.WriterMap{ //lfHook := lfshook.NewHook(lfshook.WriterMap{
log.DebugLevel: writer, // 为不同级别设置不同的输出目的 // log.DebugLevel: writer, // 为不同级别设置不同的输出目的
log.InfoLevel: writer, // log.InfoLevel: writer,
log.WarnLevel: writer, // log.WarnLevel: writer,
log.ErrorLevel: writer, // log.ErrorLevel: writer,
log.FatalLevel: writer, // log.FatalLevel: writer,
log.PanicLevel: writer, // log.PanicLevel: writer,
}, &log.JSONFormatter{}) //}, &log.JSONFormatter{})
log.AddHook(lfHook) //log.AddHook(lfHook)
} }
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"src/Common/DateTime" "src/Common/DateTime"
"src/Common/Unit" "src/Common/Unit"
"src/Config" "src/Config"
"strconv"
"time" "time"
) )
...@@ -27,7 +28,12 @@ func (this *SpModel) Start() { ...@@ -27,7 +28,12 @@ func (this *SpModel) Start() {
n = Unit.Time2Seconds(push_check_seconds) n = Unit.Time2Seconds(push_check_seconds)
} }
push_type,_:=strconv.Atoi(conf["push_type"].(string)) //0不推送,1推送
if push_type == 1 {
this.push(); this.push();
}
} }
......
...@@ -7,10 +7,10 @@ log_path = ./ ...@@ -7,10 +7,10 @@ log_path = ./
log_filename = center_service.log log_filename = center_service.log
[debug] [debug]
api_conf_sys = http://192.168.200.134:801/api/center/conf_sys api_conf_sys = http://192.168.200.134:80/api/center/conf_sys
api_conf_sps = http://192.168.200.134:801/api/center/conf_sps api_conf_sps = http://192.168.200.134:80/api/center/conf_sps
api_conf_sites = http://192.168.200.134:801/api/center/conf_sites api_conf_sites = http://192.168.200.134:80/api/center/conf_sites
api_tb_playlog_create = http://192.168.200.134:801/api/center/tb_playlog_create api_tb_playlog_create = http://192.168.200.134:80/api/center/tb_playlog_create
log_path = ./ log_path = ./
log_filename = center_service.log log_filename = center_service.log
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment