From f4526f2b7bc97b2d803441613a418a5dcb8ffa28 Mon Sep 17 00:00:00 2001 From: nxshock Date: Mon, 28 Mar 2022 18:24:23 +0500 Subject: [PATCH] Fix log formatter --- consts.go | 10 ---------- job.go | 2 +- main.go | 7 ++++++- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/consts.go b/consts.go index be0a40e..5b9b19d 100644 --- a/consts.go +++ b/consts.go @@ -1,15 +1,5 @@ package main -import formatter "github.com/antonfisher/nested-logrus-formatter" - const ( defaultConfigFilePath = "gron.conf" ) - -var ( - logFormat = &formatter.Formatter{ - TimestampFormat: config.TimeFormat, - HideKeys: true, - NoColors: true, - TrimMessages: true} -) diff --git a/job.go b/job.go index 6187454..c8de416 100644 --- a/job.go +++ b/job.go @@ -80,7 +80,7 @@ func (j *Job) Run() { l := log.New() l.SetOutput(jobLogFile) - l.SetFormatter(logFormat) + l.SetFormatter(log.StandardLogger().Formatter) log.WithField("job", j.FileName).Info("started") l.Info("started") diff --git a/main.go b/main.go index e116c19..c5b9896 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "path/filepath" "syscall" + formatter "github.com/antonfisher/nested-logrus-formatter" "github.com/robfig/cron/v3" log "github.com/sirupsen/logrus" ) @@ -28,7 +29,11 @@ func init() { log.Fatalln(err) } - log.SetFormatter(logFormat) + log.SetFormatter(&formatter.Formatter{ + TimestampFormat: config.TimeFormat, + HideKeys: true, + NoColors: true, + TrimMessages: true}) //multiWriter := io.MultiWriter(os.Stderr, logFile) //log.SetOutput(multiWriter) log.SetOutput(logFile)