Only assume important log encountered when log level is >= WARN #16735
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Prevents an issue where it assumes that a command had an important log even when
$log->info()
is called under circumstances.This is my DI config:
Basically my handlers look like this:
What is happening is that FingersCrossedHandler is the first handler and always returns
true
in$handler->isHandling()
therefore theisHandling
method on theFailureLogMessageDetector
is never called because Monolog stops as soon as one handler is returningtrue
forisHandling
see https://github.com/Seldaek/monolog/blob/1.25.5/src/Monolog/Logger.php#L303-L306By adding this extra line we make sure to only show this message (
Error: error or warning logs detected, exit 1
) and only change exit code if there's actually a warning or error no matter what handlers are defined.This is needed for the cloud otherwise our exit codes are no longer reliable as many commands simply log an info etc. Eg before
$this->logger->info("Archiving stopped by stop archiver exception");
would cause the exit code to be changed to1
when this should not be the case.We could maybe workaround it by adding fingerscrossedhandler to the end of handlers but not sure if this has other side effects and this way it always simply works.
Review