@@ -18,7 +18,9 @@ class LogsHandler implements HandlerInterface
1818 /**
1919 * The minimum logging level at which this handler will be triggered.
2020 *
21- * @var LogLevel
21+ * @psalm-suppress UndefinedDocblockClass
22+ *
23+ * @var LogLevel|\Monolog\Level|int
2224 */
2325 private $ logLevel ;
2426
@@ -32,21 +34,32 @@ class LogsHandler implements HandlerInterface
3234 /**
3335 * Creates a new Monolog handler that converts Monolog logs to Sentry logs.
3436 *
35- * @param LogLevel|null $logLevel the minimum logging level at which this handler will be triggered and collects the logs
36- * @param bool $bubble whether the messages that are handled can bubble up the stack or not
37+ * @psalm-suppress UndefinedDocblockClass
38+ *
39+ * @param LogLevel|\Monolog\Level|int|null $logLevel the minimum logging level at which this handler will be triggered and collects the logs
40+ * @param bool $bubble whether the messages that are handled can bubble up the stack or not
3741 */
38- public function __construct (? LogLevel $ logLevel = null , bool $ bubble = true )
42+ public function __construct ($ logLevel = null , bool $ bubble = true )
3943 {
4044 $ this ->logLevel = $ logLevel ?? LogLevel::debug ();
4145 $ this ->bubble = $ bubble ;
4246 }
4347
4448 /**
49+ * @psalm-suppress UndefinedDocblockClass
50+ * @psalm-suppress UndefinedClass
51+ *
4552 * @param array<string, mixed>|LogRecord $record
4653 */
4754 public function isHandling ($ record ): bool
4855 {
49- return self ::getSentryLogLevelFromMonologLevel ($ record ['level ' ])->getPriority () >= $ this ->logLevel ->getPriority ();
56+ if ($ this ->logLevel instanceof LogLevel) {
57+ return self ::getSentryLogLevelFromMonologLevel ($ record ['level ' ])->getPriority () >= $ this ->logLevel ->getPriority ();
58+ } elseif ($ this ->logLevel instanceof \Monolog \Level) {
59+ return $ record ['level ' ] >= $ this ->logLevel ->value ;
60+ }
61+
62+ return $ record ['level ' ] >= $ this ->logLevel ;
5063 }
5164
5265 /**
0 commit comments