mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-06 22:43:10 -06:00
Restore logging to file
This commit is contained in:
parent
8a855d57fe
commit
f751b3a9c1
|
|
@ -18,7 +18,6 @@
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"log/syslog"
|
"log/syslog"
|
||||||
|
|
||||||
"github.com/MFAshby/stdemuxerhook"
|
"github.com/MFAshby/stdemuxerhook"
|
||||||
|
|
@ -31,7 +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) {
|
||||||
stdLogAdded := false
|
|
||||||
for _, hook := range hooks {
|
for _, hook := range hooks {
|
||||||
// Check we received a proper logging level
|
// Check we received a proper logging level
|
||||||
level, err := logrus.ParseLevel(hook.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)
|
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 {
|
switch hook.Type {
|
||||||
case "file":
|
case "file":
|
||||||
checkFileHookParams(hook.Params)
|
checkFileHookParams(hook.Params)
|
||||||
|
|
@ -53,17 +45,10 @@ func SetupHookLogging(hooks []config.LogrusHook, componentName string) {
|
||||||
checkSyslogHookParams(hook.Params)
|
checkSyslogHookParams(hook.Params)
|
||||||
setupSyslogHook(hook, level, componentName)
|
setupSyslogHook(hook, level, componentName)
|
||||||
case "std":
|
case "std":
|
||||||
setupStdLogHook(level)
|
|
||||||
stdLogAdded = true
|
|
||||||
default:
|
default:
|
||||||
logrus.Fatalf("Unrecognised logging hook type: %s", hook.Type)
|
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{}) {
|
func checkSyslogHookParams(params map[string]interface{}) {
|
||||||
|
|
|
||||||
|
|
@ -131,9 +131,8 @@ 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()
|
|
||||||
|
|
||||||
logrus.Infof("Dendrite version %s", internal.VersionString())
|
logrus.Infof("Dendrite version %s", internal.VersionString())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue