From f751b3a9c13806f7e82e810a8c17ec2be7594c56 Mon Sep 17 00:00:00 2001 From: Piotr Kozimor Date: Wed, 3 Aug 2022 11:51:28 +0200 Subject: [PATCH] Restore logging to file --- internal/log_unix.go | 15 --------------- setup/base/base.go | 5 ++--- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/internal/log_unix.go b/internal/log_unix.go index 1e1094f23..34fd6140f 100644 --- a/internal/log_unix.go +++ b/internal/log_unix.go @@ -18,7 +18,6 @@ package internal import ( - "io/ioutil" "log/syslog" "github.com/MFAshby/stdemuxerhook" @@ -31,7 +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) { - stdLogAdded := false for _, hook := range hooks { // Check we received a proper logging level level, err := logrus.ParseLevel(hook.Level) @@ -39,12 +37,6 @@ func SetupHookLogging(hooks []config.LogrusHook, componentName string) { logrus.Fatalf("Unrecognised logging level %s: %q", hook.Level, err) } - // Perform a first filter on the logs according to the lowest level of all - // (Eg: If we have hook for info and above, prevent logrus from processing debug logs) - if logrus.GetLevel() < level { - logrus.SetLevel(level) - } - switch hook.Type { case "file": checkFileHookParams(hook.Params) @@ -53,17 +45,10 @@ func SetupHookLogging(hooks []config.LogrusHook, componentName string) { checkSyslogHookParams(hook.Params) setupSyslogHook(hook, level, componentName) case "std": - setupStdLogHook(level) - stdLogAdded = true default: logrus.Fatalf("Unrecognised logging hook type: %s", hook.Type) } } - if !stdLogAdded { - setupStdLogHook(logrus.InfoLevel) - } - // Hooks are now configured for stdout/err, so throw away the default logger output - logrus.SetOutput(ioutil.Discard) } func checkSyslogHookParams(params map[string]interface{}) { diff --git a/setup/base/base.go b/setup/base/base.go index ac912728a..044f3f694 100644 --- a/setup/base/base.go +++ b/setup/base/base.go @@ -131,9 +131,8 @@ 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() + internal.SetupHookLogging(cfg.Logging, componentName) + internal.SetupPprof() logrus.Infof("Dendrite version %s", internal.VersionString())