mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
common/log: Always output timestamps as UTC
This commit is contained in:
parent
f65e26bc2a
commit
be47984c43
1 changed files with 16 additions and 5 deletions
|
@ -8,13 +8,24 @@ import (
|
||||||
"github.com/matrix-org/dugong"
|
"github.com/matrix-org/dugong"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type utcFormatter struct {
|
||||||
|
logrus.Formatter
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f utcFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
||||||
|
entry.Time = entry.Time.UTC()
|
||||||
|
return f.Formatter.Format(entry)
|
||||||
|
}
|
||||||
|
|
||||||
// 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 := &logrus.TextFormatter{
|
formatter := &utcFormatter{
|
||||||
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
|
&logrus.TextFormatter{
|
||||||
DisableColors: true,
|
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
|
||||||
DisableTimestamp: false,
|
DisableColors: true,
|
||||||
DisableSorting: false,
|
DisableTimestamp: false,
|
||||||
|
DisableSorting: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
if logDir != "" {
|
if logDir != "" {
|
||||||
_ = os.Mkdir(logDir, os.ModePerm)
|
_ = os.Mkdir(logDir, os.ModePerm)
|
||||||
|
|
Loading…
Reference in a new issue