Skip to content
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

FingersCrossedHandler Does not check passthruLevel properly #1800

Closed
BrianMwit opened this issue Apr 6, 2023 · 1 comment · Fixed by #1801
Closed

FingersCrossedHandler Does not check passthruLevel properly #1800

BrianMwit opened this issue Apr 6, 2023 · 1 comment · Fixed by #1801
Labels
Milestone

Comments

@BrianMwit
Copy link
Contributor

BrianMwit commented Apr 6, 2023

Monolog version 3.2.1

FingersCrossedHandler have an option to passthrough log line above certain level without writing out every other lines in the request.
The filtering logic check each buffered log line if it is above or equals to the passthrough level threshold.

The level has been changed to enum, which means a simple more-than comparison will no longer work.

$this->buffer = array_filter($this->buffer, function ($record) use ($level) {
return $record->level >= $level;
});

Should be

return $record->level->value >= $level->value;

or better

return $level->includes($record->level);

We should also update test to cover this case.

/**
* @covers Monolog\Handler\FingersCrossedHandler::close
*/
public function testPassthruOnClose()
{
$test = new TestHandler();
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Level::Warning), 0, true, true, Level::Info);
$handler->handle($this->getRecord(Level::Debug));
$handler->handle($this->getRecord(Level::Info));
$handler->close();
$this->assertFalse($test->hasDebugRecords());
$this->assertTrue($test->hasInfoRecords());
}

@BrianMwit BrianMwit added the Bug label Apr 6, 2023
@stof
Copy link
Contributor

stof commented Apr 6, 2023

@BrianMwit any chance that you would open a pull request containing the fix (and the updated test) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants