1
0
mirror of https://github.com/nxshock/gron.git synced 2024-11-27 03:41:00 +05:00

Fix log formatter

This commit is contained in:
nxshock 2022-03-28 18:24:23 +05:00
parent b6bad941d9
commit f4526f2b7b
3 changed files with 7 additions and 12 deletions

View File

@ -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}
)

2
job.go
View File

@ -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")

View File

@ -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)