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:
parent
b6bad941d9
commit
f4526f2b7b
10
consts.go
10
consts.go
@ -1,15 +1,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import formatter "github.com/antonfisher/nested-logrus-formatter"
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultConfigFilePath = "gron.conf"
|
defaultConfigFilePath = "gron.conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
logFormat = &formatter.Formatter{
|
|
||||||
TimestampFormat: config.TimeFormat,
|
|
||||||
HideKeys: true,
|
|
||||||
NoColors: true,
|
|
||||||
TrimMessages: true}
|
|
||||||
)
|
|
||||||
|
2
job.go
2
job.go
@ -80,7 +80,7 @@ func (j *Job) Run() {
|
|||||||
|
|
||||||
l := log.New()
|
l := log.New()
|
||||||
l.SetOutput(jobLogFile)
|
l.SetOutput(jobLogFile)
|
||||||
l.SetFormatter(logFormat)
|
l.SetFormatter(log.StandardLogger().Formatter)
|
||||||
|
|
||||||
log.WithField("job", j.FileName).Info("started")
|
log.WithField("job", j.FileName).Info("started")
|
||||||
l.Info("started")
|
l.Info("started")
|
||||||
|
7
main.go
7
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
formatter "github.com/antonfisher/nested-logrus-formatter"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -28,7 +29,11 @@ func init() {
|
|||||||
log.Fatalln(err)
|
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)
|
//multiWriter := io.MultiWriter(os.Stderr, logFile)
|
||||||
//log.SetOutput(multiWriter)
|
//log.SetOutput(multiWriter)
|
||||||
log.SetOutput(logFile)
|
log.SetOutput(logFile)
|
||||||
|
Loading…
Reference in New Issue
Block a user