summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/app.go7
-rw-r--r--utils/config.go13
2 files changed, 14 insertions, 6 deletions
diff --git a/app/app.go b/app/app.go
index 27227d271..462c45613 100644
--- a/app/app.go
+++ b/app/app.go
@@ -125,7 +125,14 @@ func New(options ...Option) (outApp *App, outErr error) {
}
}
model.AppErrorInit(utils.T)
+
+ // The first time we load config, clear any existing filters to allow the configuration
+ // changes to take effect. This is safe only because no one else is logging at this point.
+ l4g.Close()
+
if err := app.LoadConfig(app.configFile); err != nil {
+ // Re-initialize the default logger as we bail out.
+ l4g.Global = l4g.NewDefaultLogger(l4g.DEBUG)
return nil, err
}
app.EnableConfigWatch()
diff --git a/utils/config.go b/utils/config.go
index 13295b362..6026f43f9 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -83,13 +83,15 @@ func ConfigureCmdLineLog() {
ConfigureLog(&ls)
}
+// ConfigureLog enables and configures logging.
+//
+// Note that it is not currently possible to disable filters nor to modify previously enabled
+// filters, given the lack of concurrency guarantees from the underlying l4g library.
+//
// TODO: this code initializes console and file logging. It will eventually be replaced by JSON logging in logger/logger.go
// See PLT-3893 for more information
func ConfigureLog(s *model.LogSettings) {
-
- l4g.Close()
-
- if s.EnableConsole {
+ if _, alreadySet := l4g.Global["stdout"]; !alreadySet && s.EnableConsole {
level := l4g.DEBUG
if s.ConsoleLevel == "INFO" {
level = l4g.INFO
@@ -104,8 +106,7 @@ func ConfigureLog(s *model.LogSettings) {
l4g.AddFilter("stdout", level, lw)
}
- if s.EnableFile {
-
+ if _, alreadySet := l4g.Global["file"]; !alreadySet && s.EnableFile {
var fileFormat = s.FileFormat
if fileFormat == "" {