-
Notifications
You must be signed in to change notification settings - Fork 1
Write logs according the verbosity level defined #11
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
Conversation
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.
Hey @erickhun, thanks for this work 🌮
I think monolog already supports this feature. If I am not mistaken we could configure it by passing it as the second parameter to the StreamHandler constructor:
$logLevelFromEnv = getenv(self::$logLevelEnvVar);
$handler = new StreamHandler('php://stdout', $logLevelFromEnv);I may be missing some context on the requirements as there may be good reasons to build our own. If that's the case, this implementation LGTM 👍 I left a couple of small comments below. Nothing blocking!
src/BuffLog/BuffLog.php
Outdated
| $logLevelFromEnv = getenv(self::$logLevelEnvVar); | ||
| $monologLevels = self::getLogger()->getLevels(); |
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.
We could slide this two lines out and pass $logLevel to the setVerbosityLevel as an argument. That way this method becomes a setter that could be used to configure the verbosity level in user land. I don't think that's going to happen very often, though.
src/BuffLog/BuffLog.php
Outdated
| // Optimization: we could move this at the singleton initialization | ||
| self::setVerbosityLevel(); |
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.
:plus-one: to that optimization comment 👍
|
@esclapes oh wow , great spot, I didn't spot that feature 🙈 This will greatly simplify the code 🤩. Let me rework the code and loop you again with this |
|
@esclapes I've reworked the code with using the |
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.
Looks good to me! 👍
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.
Great that it helped @erickhun LGTM! 🌮 👍
This PR will :
LOG_LEVELin the env variableNOTICElevelI use Monolog levels for now until we decide the final ones
@colinscape @esclapes Can I have your eyes on this ?