Skip to content

Commit

Permalink
Allow only monolog 2
Browse files Browse the repository at this point in the history
  • Loading branch information
GDXbsv committed Oct 7, 2024
1 parent 45b8e9b commit a41a3af
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "library",
"require": {
"php": "^8.2",
"monolog/monolog": "^3",
"monolog/monolog": "^2",
"open-telemetry/opentelemetry-logger-monolog": "^1.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function format(LogRecord $record): string
public function format(array $record): string
{
/** @var array{timestamp: int, datetime: string, extra?:array, context?:array} $data */
$data = parent::format($record);
Expand Down
3 changes: 1 addition & 2 deletions src/Laravel/LaravelLoggerCreating.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use GuzzleHttp\Exception\RequestException;
use Illuminate\Support\Facades\App;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\Logger;
use Monolog\Processor\ProcessorInterface;
use Monolog\Processor\PsrLogMessageProcessor;
Expand All @@ -35,7 +34,7 @@ public function __invoke(array $config)
/** @var array<string, array<array-key, callable>> $exceptionContexts */
$exceptionContexts = $config['exceptionContexts'] ?? [];
/** @var int $level */
$level = $config['level'] ?? Level::Debug;
$level = $config['level'] ?? Logger::DEBUG;
/** @var string $stream */
$stream = $config['stream_to'] ?? 'php://stderr';

Expand Down
10 changes: 4 additions & 6 deletions src/NewrelicProcessor.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);

namespace Gotphoto\Logging;

use Monolog\LogRecord;
use Monolog\Processor\ProcessorInterface;

/**
Expand All @@ -14,15 +14,13 @@ class NewrelicProcessor implements ProcessorInterface
* Returns the given record with the New Relic linking metadata added
* if a compatible New Relic extension is loaded, otherwise returns the
* given record unmodified
*
* @return LogRecord The processed record
*/
public function __invoke(LogRecord $record)
public function __invoke(array $record)
{
if (function_exists('newrelic_get_linking_metadata')) {
/** @var array $linking_data */
$linking_data = newrelic_get_linking_metadata();
$record->extra['newrelic-context'] = $linking_data;
$record['extra']['newrelic-context'] = $linking_data;
}
return $record;
}
Expand Down

0 comments on commit a41a3af

Please sign in to comment.