-
-
Notifications
You must be signed in to change notification settings - Fork 453
/
Copy pathRecordFactory.php
46 lines (41 loc) · 1.38 KB
/
RecordFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace Sentry\Tests\Monolog;
use DateTimeImmutable;
use Monolog\Logger;
use Monolog\LogRecord;
/**
* @internal
*/
final class RecordFactory
{
/**
* @param Logger::DEBUG|Logger::INFO|Logger::NOTICE|Logger::WARNING|Logger::ERROR|Logger::CRITICAL|Logger::ALERT|Logger::EMERGENCY $level The Monolog log level
* @param array<string, mixed> $context
* @param array<string, mixed> $extra
*
* @return array<string, mixed>|LogRecord
*/
public static function create(string $message, int $level, string $channel, array $context, array $extra)
{
if (Logger::API >= 3) {
return new LogRecord(
new DateTimeImmutable(),
$channel,
Logger::toMonologLevel($level),
$message,
$context,
$extra
);
}
return [
'message' => $message,
'context' => $context,
'level' => $level,
'level_name' => Logger::getLevelName($level),
'channel' => $channel,
'extra' => $extra,
'datetime' => new \DateTimeImmutable(),
];
}
}