|
2 | 2 |
|
3 | 3 | namespace Sentry\Laravel\Logs; |
4 | 4 |
|
5 | | -use Illuminate\Support\Arr; |
6 | | -use Monolog\Level; |
7 | 5 | use Sentry\Logs\LogLevel; |
8 | 6 | use Monolog\Formatter\LineFormatter; |
9 | 7 | use Monolog\Formatter\FormatterInterface; |
10 | 8 | use Monolog\Handler\AbstractProcessingHandler; |
11 | 9 | use Sentry\Monolog\CompatibilityProcessingHandlerTrait; |
| 10 | +use Sentry\Severity; |
12 | 11 | use Throwable; |
13 | 12 |
|
14 | 13 | class LogsHandler extends AbstractProcessingHandler |
@@ -103,28 +102,27 @@ protected function doWrite($record): void |
103 | 102 | } |
104 | 103 |
|
105 | 104 | \Sentry\logger()->aggregator()->add( |
106 | | - $this->getLevelFromMonologLevel($record['level']), |
| 105 | + // This seems a little bit of a roundabout way to get the log level, but this is done for compatibility |
| 106 | + self::getLogLevelFromSeverity( |
| 107 | + self::getSeverityFromLevel($record['level']) |
| 108 | + ), |
107 | 109 | $record['message'], |
108 | 110 | [], |
109 | 111 | array_merge($record['context'], $record['extra']) |
110 | 112 | ); |
111 | 113 | } |
112 | 114 |
|
113 | | - private function getLevelFromMonologLevel(int $level): LogLevel |
| 115 | + private static function getLogLevelFromSeverity(Severity $severity): LogLevel |
114 | 116 | { |
115 | | - switch (Level::from($level)) { |
116 | | - case Level::Debug: |
| 117 | + switch ($severity) { |
| 118 | + case Severity::debug(): |
117 | 119 | return LogLevel::debug(); |
118 | | - case Level::Warning: |
| 120 | + case Severity::warning(): |
119 | 121 | return LogLevel::warn(); |
120 | | - case Level::Error: |
| 122 | + case Severity::error(): |
121 | 123 | return LogLevel::error(); |
122 | | - case Level::Critical: |
123 | | - case Level::Alert: |
124 | | - case Level::Emergency: |
| 124 | + case Severity::fatal(): |
125 | 125 | return LogLevel::fatal(); |
126 | | - case Level::Info: |
127 | | - case Level::Notice: |
128 | 126 | default: |
129 | 127 | return LogLevel::info(); |
130 | 128 | } |
|
0 commit comments