-
Notifications
You must be signed in to change notification settings - Fork 3
Postpone log level detection until OC loaded #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Postpone log level detection until OC loaded #384
Conversation
|
Encountered this error when adding a new Vue component to core nextcloud/server#35637 and this seems to fix it! Thanks! |
PVince81
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 but please adjust the version as @Pytal mentionned
| this.detectLogLevel() | ||
| } | ||
|
|
||
| return this.factory(this.context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is called regardless of the log level being read already or later after page load.
in other words, if this.context.level is changed at a later stage, it won't have an affect on the already created logger instance, will it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will, as the object is not deep copied but passed by reference so the logger and the logger builder share the same context (until the site it loaded).
I pushed two additional commits providing test cases for this scenario.
(I hope this is ok, normally I would open a new PR for a new feature but I think the tests belong to this)
Sometimes the logger is loaded before the OC variable is declared, so we need to wait for OC to become available. Signed-off-by: Ferdinand Thiessen <[email protected]>
…n for NC25 Signed-off-by: Ferdinand Thiessen <[email protected]>
Also added mocks for the logger itself. Signed-off-by: Ferdinand Thiessen <[email protected]>
Signed-off-by: Ferdinand Thiessen <[email protected]>
While #383 only fixed the symptoms, this will fix the root issue that sometimes the logger is loaded before the OC variable is declared, So we need to wait for OC to become available.
Currently the behavior is nondeterministic because if the logger is loaded before the global
OCvariable was set the logger would never respect the configured logging level and stick with the default (warning even if you configured e.g. info on the back end).So you might even loose some messages.
This PR will change the behavior to a deterministic one:
Until the
OCvariable is set and the level was not set manually, the logger will no use any logging level (equivalent to debug).When the
OCvariable is set the logger will switch to that logging level.So the logger is independent to the loading order of the scripts.