Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Commit 74d1a8d

Browse files
committed
feat: Bump For Laravel 7.x
MonologFormatter has a new signature.
1 parent 9b43e38 commit 74d1a8d

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
}
2929
],
3030
"require": {
31-
"php": ">=7.1",
32-
"laravel/framework": "^5.6|^5.7|^5.8|^6.0|^7.0|^8.0",
31+
"php": ">=7.2.5",
32+
"laravel/framework": "^7.0|^8.0",
3333
"guzzlehttp/guzzle": "^6.0|^7.0"
3434
},
3535
"require-dev": {

src/DataDogFormatter.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class DataDogFormatter extends JsonFormatter
1818

1919
const LARAVEL_LOG_DATETIME_KEY = 'datetime';
2020

21+
public function __construct(
22+
int $batchMode = self::BATCH_MODE_JSON,
23+
bool $appendNewline = true,
24+
bool $ignoreEmptyContextAndExtra = false
25+
) {
26+
parent::__construct($batchMode, $appendNewline, $ignoreEmptyContextAndExtra);
27+
}
28+
2129
/**
2230
* Appends every variable needed by DataDog
2331
*
@@ -29,13 +37,10 @@ class DataDogFormatter extends JsonFormatter
2937
* @see \Monolog\Formatter\JsonFormatter::format()
3038
* @see https://docs.datadoghq.com/logs/processing/#reserved-attributes
3139
*/
32-
public function format(array $record)
40+
public function format(array $record): string
3341
{
3442
if (isset($record[self::LARAVEL_LOG_DATETIME_KEY]) &&
3543
($record[self::LARAVEL_LOG_DATETIME_KEY] instanceof DateTime)) {
36-
/**
37-
* @var DateTime $dateTimeObj
38-
*/
3944
$dateTimeObj = $record[self::LARAVEL_LOG_DATETIME_KEY];
4045
$record['published_date'] = $dateTimeObj->format(DateTime::ISO8601);
4146
}

tests/Agent/DataDogAgentFormatterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function recordProvider()
7272
"datetime" => new Carbon('2019-08-14 09:58:10.764107', 'UTC'),
7373
"extra" => []
7474
],
75-
'{"message":"test","context":[],"level":200,"level_name":"INFO","channel":null,"datetime":"2019-08-14T09:58:10.764107Z","extra":[],"published_date":"2019-08-14T09:58:10+0000","status":"INFO","ddsource":"php-cli","source":"php-cli","service":"laravel-datadog-logger","hostname":"foohostname"}' . PHP_EOL
75+
'{"message":"test","context":{},"level":200,"level_name":"INFO","channel":null,"datetime":"2019-08-14T09:58:10.764107Z","extra":{},"published_date":"2019-08-14T09:58:10+0000","status":"INFO","ddsource":"php-cli","source":"php-cli","service":"laravel-datadog-logger","hostname":"foohostname"}' . PHP_EOL
7676
],
7777
[
7878
[
@@ -86,7 +86,7 @@ public function recordProvider()
8686
"datetime" => new Carbon('2019-08-14 09:58:10.764107', 'UTC'),
8787
"extra" => []
8888
],
89-
'{"message":"test","context":{"toto":"tata"},"level":100,"level_name":"DEBUG","channel":null,"datetime":"2019-08-14T09:58:10.764107Z","extra":[],"published_date":"2019-08-14T09:58:10+0000","status":"DEBUG","ddsource":"php-cli","source":"php-cli","service":"laravel-datadog-logger","hostname":"foohostname"}' . PHP_EOL
89+
'{"message":"test","context":{"toto":"tata"},"level":100,"level_name":"DEBUG","channel":null,"datetime":"2019-08-14T09:58:10.764107Z","extra":{},"published_date":"2019-08-14T09:58:10+0000","status":"DEBUG","ddsource":"php-cli","source":"php-cli","service":"laravel-datadog-logger","hostname":"foohostname"}' . PHP_EOL
9090
]
9191
];
9292

tests/DataDogFormatterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function recordProvider()
5353
"datetime" => new Carbon('2019-08-14 09:58:10.764107', 'UTC'),
5454
"extra" => []
5555
],
56-
'{"message":"test","context":[],"level":200,"level_name":"INFO","channel":null,"datetime":"2019-08-14T09:58:10.764107Z","extra":[],"published_date":"2019-08-14T09:58:10+0000","status":"INFO","ddsource":"php-cli","source":"php-cli","service":"laravel-datadog-logger","hostname":"foohostname"}' . PHP_EOL
56+
'{"message":"test","context":{},"level":200,"level_name":"INFO","channel":null,"datetime":"2019-08-14T09:58:10.764107Z","extra":{},"published_date":"2019-08-14T09:58:10+0000","status":"INFO","ddsource":"php-cli","source":"php-cli","service":"laravel-datadog-logger","hostname":"foohostname"}' . PHP_EOL
5757
],
5858
[
5959
[
@@ -67,7 +67,7 @@ public function recordProvider()
6767
"datetime" => new Carbon('2019-08-14 09:58:10.764107', 'UTC'),
6868
"extra" => []
6969
],
70-
'{"message":"test","context":{"toto":"tata"},"level":100,"level_name":"DEBUG","channel":null,"datetime":"2019-08-14T09:58:10.764107Z","extra":[],"published_date":"2019-08-14T09:58:10+0000","status":"DEBUG","ddsource":"php-cli","source":"php-cli","service":"laravel-datadog-logger","hostname":"foohostname"}' . PHP_EOL
70+
'{"message":"test","context":{"toto":"tata"},"level":100,"level_name":"DEBUG","channel":null,"datetime":"2019-08-14T09:58:10.764107Z","extra":{},"published_date":"2019-08-14T09:58:10+0000","status":"DEBUG","ddsource":"php-cli","source":"php-cli","service":"laravel-datadog-logger","hostname":"foohostname"}' . PHP_EOL
7171
]
7272
];
7373

0 commit comments

Comments
 (0)