Revert logging formatter changes to log.go, base.go.

The same formatting should be applied on both windows and unix, so it
makes sense to keep it in files which are shared between both platforms.

Fixes
https://github.com/matrix-org/dendrite/pull/2060#discussion_r762557679
This commit is contained in:
Martin Ashby 2021-12-07 11:51:47 +00:00
parent abd370a133
commit f886fbc917
No known key found for this signature in database
GPG key ID: 7C2A95403085B982
3 changed files with 16 additions and 11 deletions

View file

@ -91,6 +91,21 @@ func SetupPprof() {
} }
} }
// SetupStdLogging configures the logging format to standard output. Typically, it is called when the config is not yet loaded.
func SetupStdLogging() {
logrus.SetReportCaller(true)
logrus.SetFormatter(&utcFormatter{
&logrus.TextFormatter{
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
FullTimestamp: true,
DisableColors: false,
DisableTimestamp: false,
QuoteEmptyFields: true,
CallerPrettyfier: callerPrettyfier,
},
})
}
// File type hooks should be provided a path to a directory to store log files // File type hooks should be provided a path to a directory to store log files
func checkFileHookParams(params map[string]interface{}) { func checkFileHookParams(params map[string]interface{}) {
path, ok := params["path"] path, ok := params["path"]

View file

@ -30,17 +30,6 @@ import (
// If something fails here it means that the logging was improperly configured, // If something fails here it means that the logging was improperly configured,
// so we just exit with the error // so we just exit with the error
func SetupHookLogging(hooks []config.LogrusHook, componentName string) { func SetupHookLogging(hooks []config.LogrusHook, componentName string) {
logrus.SetReportCaller(true)
logrus.SetFormatter(&utcFormatter{
&logrus.TextFormatter{
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
FullTimestamp: true,
DisableColors: false,
DisableTimestamp: false,
QuoteEmptyFields: true,
CallerPrettyfier: callerPrettyfier,
},
})
stdLogAdded := false stdLogAdded := false
for _, hook := range hooks { for _, hook := range hooks {
// Check we received a proper logging level // Check we received a proper logging level

View file

@ -123,6 +123,7 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base
logrus.Fatalf("Failed to start due to configuration errors") logrus.Fatalf("Failed to start due to configuration errors")
} }
internal.SetupStdLogging()
internal.SetupHookLogging(cfg.Logging, componentName) internal.SetupHookLogging(cfg.Logging, componentName)
internal.SetupPprof() internal.SetupPprof()