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
Refactor log level configuration #7695
Conversation
- Remove STRAPI_LOG_LEVEL environment variable related redundant code. - Add helpful error message to the current log level configuration system. Signed-off-by: Juho Viitasalo <juho.viitasalo@lildrop.com>
Signed-off-by: Juho Viitasalo <juho.viitasalo@lildrop.com>
Codecov Report
@@ Coverage Diff @@
## master #7695 +/- ##
==========================================
+ Coverage 27.23% 33.01% +5.78%
==========================================
Files 1163 1219 +56
Lines 15532 13571 -1961
Branches 2411 1349 -1062
==========================================
+ Hits 4230 4481 +251
+ Misses 9534 8207 -1327
+ Partials 1768 883 -885
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Hello, I don't understand what this PR adds ? it is actually a breaking change |
Have you read the issue? PR removes some redundant and confusing code that doesn't do anything anymore. It is not a breaking change. |
Is it possible this pull request gets accepted? I might need some help passing the code coverage check. I'm not sure what to do with it. |
That's actually not that simple :). The logger can be and is used outside of the middleware and might be required (e.g in command line) without the middleware being instantiated. in those usecases the env var is usefull. We need to make sure the standalone logger offers the previous features it has without have to depend on its log level being instantiate in the middleware. I Hope that makes sense. |
That makes perfect sense. Do you still think it's a good idea to still add the validation part? Do we need to add tests for these features? In any case when this is settled I'll try to do another pull request to add some docs. |
Sure doing some validation is alright :) And tests are always welcome 👍 |
Hi @jiv-e will you be able to finish this PR ? |
Hi @alexandrebodin, |
@@ -25,14 +26,31 @@ module.exports = strapi => { | |||
initialize() { | |||
const { level, exposeInContext, requests } = strapi.config.middleware.settings.logger; | |||
|
|||
if (level) { | |||
strapi.log.level = level; | |||
const logLevels = ['fatal', 'error', 'warn', 'info', 'debug', 'trace']; |
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.
Can you use the levels available at strapi.log.levels to avoid having to maintain this list :)
const logLevels = Object.keys(strapi.log.levels.values);
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.
Good idea.
Hey @jiv-e almost there :) WIll you be able to apply the last feedbacks to your PR ? |
Done.. I also added validation for STRAPI_LOG_LEVEL. |
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.
LGTM 👍
system.
Fixes #7673