Repository: Seldaek/monolog (php)

Issue:
FingersCrossedHandler Does not check passthruLevel properly
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.
https://github.com/Seldaek/monolog/blob/b05bf55097060ec20f49ccec0cf2f8e5aaa468b3/src/Monolog/Handler/FingersCrossedHandler.php#L185-L187
Should be
```php
return $record->level->value >= $level->value;
```
or better
```php
return $level->includes($record->level);
```

We should also update test to cover this case.
https://github.com/Seldaek/monolog/blob/b05bf55097060ec20f49ccec0cf2f8e5aaa468b3/tests/Monolog/Handler/FingersCrossedHandlerTest.php#L253-L265

Pull request description:
FingersCrossedHandler fix passthruLevel checking (Fixes #1800)
Fixes https://github.com/Seldaek/monolog/issues/1800

Patch:
diff --git a/src/Monolog/Handler/FingersCrossedHandler.php b/src/Monolog/Handler/FingersCrossedHandler.php
index ce2a3a8e..888ec998 100644
--- a/src/Monolog/Handler/FingersCrossedHandler.php
+++ b/src/Monolog/Handler/FingersCrossedHandler.php
@@ -181,9 +181,8 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
     private function flushBuffer(): void
     {
         if (null !== $this->passthruLevel) {
-            $level = $this->passthruLevel;
-            $this->buffer = array_filter($this->buffer, function ($record) use ($level) {
-                return $record->level >= $level;
+            $this->buffer = array_filter($this->buffer, function ($record) {
+                return $this->passthruLevel->includes($record->level);
             });
             if (count($this->buffer) > 0) {
                 $this->getHandler(end($this->buffer))->handleBatch($this->buffer);


Test patch:
diff --git a/tests/Monolog/Handler/FingersCrossedHandlerTest.php b/tests/Monolog/Handler/FingersCrossedHandlerTest.php
index 702a5f08..ba01b9f6 100644
--- a/tests/Monolog/Handler/FingersCrossedHandlerTest.php
+++ b/tests/Monolog/Handler/FingersCrossedHandlerTest.php
@@ -259,9 +259,11 @@ class FingersCrossedHandlerTest extends TestCase
         $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->handle($this->getRecord(Level::Notice));
         $handler->close();
         $this->assertFalse($test->hasDebugRecords());
         $this->assertTrue($test->hasInfoRecords());
+        $this->assertTrue($test->hasNoticeRecords());
     }
 
     /**
@@ -273,8 +275,10 @@ class FingersCrossedHandlerTest extends TestCase
         $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Level::Warning), 0, true, true, LogLevel::INFO);
         $handler->handle($this->getRecord(Level::Debug));
         $handler->handle($this->getRecord(Level::Info));
+        $handler->handle($this->getRecord(Level::Notice));
         $handler->close();
         $this->assertFalse($test->hasDebugRecords());
         $this->assertTrue($test->hasInfoRecords());
+        $this->assertTrue($test->hasNoticeRecords());
     }
 }