diff --git a/internal/log.go b/internal/log.go index ea44e22b5..bba0ac6e6 100644 --- a/internal/log.go +++ b/internal/log.go @@ -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 func checkFileHookParams(params map[string]interface{}) { path, ok := params["path"] diff --git a/internal/log_unix.go b/internal/log_unix.go index 44cb75beb..27d9a8fe6 100644 --- a/internal/log_unix.go +++ b/internal/log_unix.go @@ -30,17 +30,6 @@ import ( // If something fails here it means that the logging was improperly configured, // so we just exit with the error 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 for _, hook := range hooks { // Check we received a proper logging level diff --git a/setup/base/base.go b/setup/base/base.go index 1249e1422..9ba88bef7 100644 --- a/setup/base/base.go +++ b/setup/base/base.go @@ -123,6 +123,7 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base logrus.Fatalf("Failed to start due to configuration errors") } + internal.SetupStdLogging() internal.SetupHookLogging(cfg.Logging, componentName) internal.SetupPprof()