common/log: Always log to stderr

This commit is contained in:
Robert Swain 2017-04-21 02:10:54 +02:00
parent 27beb8a2b3
commit 9b7defd375

View File

@ -33,6 +33,15 @@ func (f utcFormatter) Format(entry *logrus.Entry) ([]byte, error) {
// SetupLogging configures the logging format and destination(s). // SetupLogging configures the logging format and destination(s).
func SetupLogging(logDir string) { func SetupLogging(logDir string) {
logrus.SetFormatter(&utcFormatter{
&logrus.TextFormatter{
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
FullTimestamp: true,
DisableColors: false,
DisableTimestamp: false,
DisableSorting: false,
},
})
if logDir != "" { if logDir != "" {
_ = os.Mkdir(logDir, os.ModePerm) _ = os.Mkdir(logDir, os.ModePerm)
logrus.AddHook(dugong.NewFSHook( logrus.AddHook(dugong.NewFSHook(
@ -49,15 +58,5 @@ func SetupLogging(logDir string) {
}, },
&dugong.DailyRotationSchedule{GZip: true}, &dugong.DailyRotationSchedule{GZip: true},
)) ))
} else {
logrus.SetFormatter(&utcFormatter{
&logrus.TextFormatter{
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
FullTimestamp: true,
DisableColors: false,
DisableTimestamp: false,
DisableSorting: false,
},
})
} }
} }