diff options
author | Derrick Anderson <derrick@andersonwebstudio.com> | 2018-04-17 09:49:02 -0400 |
---|---|---|
committer | Derrick Anderson <derrick@andersonwebstudio.com> | 2018-04-17 09:49:02 -0400 |
commit | af98bf1d49b418a7cf99f28983899839ae101851 (patch) | |
tree | a0e08fec9446ac58fb0e460f48446fc117fc3e66 | |
parent | 997df03ac1455785b7a39e40edcd67b3b3e86f9e (diff) | |
parent | 58e559da396ccb0f170c4304974c26d728cab637 (diff) | |
download | chat-af98bf1d49b418a7cf99f28983899839ae101851.tar.gz chat-af98bf1d49b418a7cf99f28983899839ae101851.tar.bz2 chat-af98bf1d49b418a7cf99f28983899839ae101851.zip |
Merge branch 'merge49final'
-rw-r--r-- | app/app.go | 7 | ||||
-rw-r--r-- | app/authorization.go | 7 | ||||
-rw-r--r-- | utils/config.go | 13 |
3 files changed, 15 insertions, 12 deletions
diff --git a/app/app.go b/app/app.go index 43f598f79..51ee37cbd 100644 --- a/app/app.go +++ b/app/app.go @@ -126,7 +126,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/app/authorization.go b/app/authorization.go index 632dd7566..2187472f7 100644 --- a/app/authorization.go +++ b/app/authorization.go @@ -12,12 +12,7 @@ import ( ) func (a *App) SessionHasPermissionTo(session model.Session, permission *model.Permission) bool { - if !a.RolesGrantPermission(session.GetUserRoles(), permission.Id) { - a.ClearSessionCacheForUser(session.UserId) - return false - } - - return true + return a.RolesGrantPermission(session.GetUserRoles(), permission.Id) } /// DO NOT USE: LEGACY diff --git a/utils/config.go b/utils/config.go index 7032dbad9..fa436f70d 100644 --- a/utils/config.go +++ b/utils/config.go @@ -84,13 +84,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 @@ -105,8 +107,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 == "" { |