Skip to content

Commit a41a3af

Browse files
committed
Allow only monolog 2
1 parent 45b8e9b commit a41a3af

4 files changed

Lines changed: 7 additions & 10 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "library",
55
"require": {
66
"php": "^8.2",
7-
"monolog/monolog": "^3",
7+
"monolog/monolog": "^2",
88
"open-telemetry/opentelemetry-logger-monolog": "^1.0"
99
},
1010
"require-dev": {

src/Formatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(
4747
/**
4848
* {@inheritdoc}
4949
*/
50-
public function format(LogRecord $record): string
50+
public function format(array $record): string
5151
{
5252
/** @var array{timestamp: int, datetime: string, extra?:array, context?:array} $data */
5353
$data = parent::format($record);

src/Laravel/LaravelLoggerCreating.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use GuzzleHttp\Exception\RequestException;
1414
use Illuminate\Support\Facades\App;
1515
use Monolog\Handler\StreamHandler;
16-
use Monolog\Level;
1716
use Monolog\Logger;
1817
use Monolog\Processor\ProcessorInterface;
1918
use Monolog\Processor\PsrLogMessageProcessor;
@@ -35,7 +34,7 @@ public function __invoke(array $config)
3534
/** @var array<string, array<array-key, callable>> $exceptionContexts */
3635
$exceptionContexts = $config['exceptionContexts'] ?? [];
3736
/** @var int $level */
38-
$level = $config['level'] ?? Level::Debug;
37+
$level = $config['level'] ?? Logger::DEBUG;
3938
/** @var string $stream */
4039
$stream = $config['stream_to'] ?? 'php://stderr';
4140

src/NewrelicProcessor.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
declare(strict_types=1);
23

34
namespace Gotphoto\Logging;
45

5-
use Monolog\LogRecord;
66
use Monolog\Processor\ProcessorInterface;
77

88
/**
@@ -14,15 +14,13 @@ class NewrelicProcessor implements ProcessorInterface
1414
* Returns the given record with the New Relic linking metadata added
1515
* if a compatible New Relic extension is loaded, otherwise returns the
1616
* given record unmodified
17-
*
18-
* @return LogRecord The processed record
1917
*/
20-
public function __invoke(LogRecord $record)
18+
public function __invoke(array $record)
2119
{
2220
if (function_exists('newrelic_get_linking_metadata')) {
2321
/** @var array $linking_data */
2422
$linking_data = newrelic_get_linking_metadata();
25-
$record->extra['newrelic-context'] = $linking_data;
23+
$record['extra']['newrelic-context'] = $linking_data;
2624
}
2725
return $record;
2826
}

0 commit comments

Comments
 (0)