mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
common/log: Re-colorize terminal log output
This commit is contained in:
parent
9b7bf8cba8
commit
27beb8a2b3
1 changed files with 17 additions and 10 deletions
|
@ -33,24 +33,31 @@ 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) {
|
||||||
formatter := &utcFormatter{
|
|
||||||
&logrus.TextFormatter{
|
|
||||||
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
|
|
||||||
DisableColors: true,
|
|
||||||
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(
|
||||||
filepath.Join(logDir, "info.log"),
|
filepath.Join(logDir, "info.log"),
|
||||||
filepath.Join(logDir, "warn.log"),
|
filepath.Join(logDir, "warn.log"),
|
||||||
filepath.Join(logDir, "error.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},
|
&dugong.DailyRotationSchedule{GZip: true},
|
||||||
))
|
))
|
||||||
} else {
|
} 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,
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue