From 27beb8a2b390985897923ca612c950a12f5554a6 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Fri, 21 Apr 2017 02:06:06 +0200 Subject: [PATCH] common/log: Re-colorize terminal log output --- .../matrix-org/dendrite/common/log.go | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/common/log.go b/src/github.com/matrix-org/dendrite/common/log.go index e6d79458..b8ea9547 100644 --- a/src/github.com/matrix-org/dendrite/common/log.go +++ b/src/github.com/matrix-org/dendrite/common/log.go @@ -33,24 +33,31 @@ func (f utcFormatter) Format(entry *logrus.Entry) ([]byte, error) { // SetupLogging configures the logging format and destination(s). func SetupLogging(logDir string) { - formatter := &utcFormatter{ - &logrus.TextFormatter{ - TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00", - DisableColors: true, - DisableTimestamp: false, - DisableSorting: false, - }, - } if logDir != "" { _ = os.Mkdir(logDir, os.ModePerm) logrus.AddHook(dugong.NewFSHook( filepath.Join(logDir, "info.log"), filepath.Join(logDir, "warn.log"), filepath.Join(logDir, "error.log"), - formatter, + &utcFormatter{ + &logrus.TextFormatter{ + TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00", + DisableColors: true, + DisableTimestamp: false, + DisableSorting: false, + }, + }, &dugong.DailyRotationSchedule{GZip: true}, )) } else { - logrus.SetFormatter(formatter) + logrus.SetFormatter(&utcFormatter{ + &logrus.TextFormatter{ + TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00", + FullTimestamp: true, + DisableColors: false, + DisableTimestamp: false, + DisableSorting: false, + }, + }) } }