Skip to content
12 changes: 11 additions & 1 deletion src/Monolog/LogsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function handle($record): bool
self::getSentryLogLevelFromMonologLevel($record['level']),
$record['message'],
[],
array_merge($record['context'], $record['extra'], ['sentry.origin' => 'auto.log.monolog'])
$this->compileAttributes($record)
);

return $this->bubble === false;
Expand Down Expand Up @@ -123,4 +123,14 @@ public function __destruct()
// Just in case so that the destructor can never fail.
}
}

/**
* @param array<string,mixed>|LogRecord $record
*
* @return array<string,mixed>
*/
protected function compileAttributes($record): array
{
return array_merge($record['context'], $record['extra'], ['sentry.origin' => 'auto.log.monolog']);
}
}