LogMessage.php
1.0 KB
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
47
<?php
namespace Facade\Ignition\LogRecorder;
use Illuminate\Log\Events\MessageLogged;
class LogMessage
{
/** @var string */
protected $message;
/** @var array */
protected $context;
/** @var string */
protected $level;
/** @var float */
protected $microtime;
public function __construct(?string $message, string $level, array $context = [], ?float $microtime = null)
{
$this->message = $message;
$this->level = $level;
$this->context = $context;
$this->microtime = $microtime ?? microtime(true);
}
public static function fromMessageLoggedEvent(MessageLogged $event): self
{
return new self(
$event->message,
$event->level,
$event->context
);
}
public function toArray()
{
return [
'message' => $this->message,
'level' => $this->level,
'context' => $this->context,
'microtime' => $this->microtime,
];
}
}