cmd: configurable logrus formatters

We lost the nice context-stack [jobname][taskname][...] at the beginning
of each log line when switching to logrus.

Define some field names that define these contexts.
Write a human-friendly formatter that presents these field names like
the solution we had before logrus.

Write some other formatters for logfmt and json output along the way.

Limit ourselves to stdout logging for now.
This commit is contained in:
Christian Schwarz
2017-09-23 11:24:36 +02:00
parent 3ff9e6d2f7
commit 9465b593f9
10 changed files with 187 additions and 101 deletions

View File

@ -73,7 +73,7 @@ func (d *Daemon) Loop(ctx context.Context) {
for _, job := range d.conf.Jobs {
log.Printf("starting job %s", job.JobName())
logger := log.WithField("job", job.JobName())
logger := log.WithField(logJobField, job.JobName())
i++
jobCtx := context.WithValue(ctx, contextKeyLog, logger)
go func(j Job) {