1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Ecodev\Felix\Model\Traits; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use GraphQL\Doctrine\Attribute as API; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Log. |
12
|
|
|
*/ |
13
|
|
|
trait Log |
14
|
|
|
{ |
15
|
|
|
use HasUrl; |
16
|
|
|
|
17
|
|
|
#[ORM\Column(type: 'smallint')] |
18
|
|
|
private int $level; |
19
|
|
|
|
20
|
|
|
#[ORM\Column(type: 'string', length: 5000)] |
21
|
|
|
private string $message = ''; |
22
|
|
|
|
23
|
|
|
#[ORM\Column(type: 'string', length: 500, options: ['default' => ''])] |
24
|
|
|
private string $referer = ''; |
25
|
|
|
|
26
|
|
|
#[ORM\Column(type: 'string', length: 1000, options: ['default' => ''])] |
27
|
|
|
private string $request = ''; |
28
|
|
|
|
29
|
|
|
#[ORM\Column(type: 'string', length: 40, options: ['default' => ''])] |
30
|
|
|
private string $ip = ''; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The data submitted when calling `_log()->info()`. |
34
|
|
|
*/ |
35
|
|
|
#[ORM\Column(type: 'json', options: ['default' => '{}'])] |
36
|
|
|
#[API\Exclude] |
37
|
|
|
private array $context = []; |
38
|
|
|
|
39
|
|
|
public function setLevel(int $level): void |
40
|
|
|
{ |
41
|
|
|
$this->level = $level; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function getLevel(): int |
45
|
|
|
{ |
46
|
|
|
return $this->level; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Set message. |
51
|
|
|
*/ |
52
|
|
|
public function setMessage(string $message): void |
53
|
|
|
{ |
54
|
|
|
$this->message = $message; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Get message. |
59
|
|
|
*/ |
60
|
|
|
public function getMessage(): string |
61
|
|
|
{ |
62
|
|
|
return $this->message; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Set referer. |
67
|
|
|
*/ |
68
|
|
|
public function setReferer(string $referer): void |
69
|
|
|
{ |
70
|
|
|
$this->referer = $referer; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Get referer. |
75
|
|
|
*/ |
76
|
|
|
public function getReferer(): string |
77
|
|
|
{ |
78
|
|
|
return $this->referer; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Set request. |
83
|
|
|
*/ |
84
|
|
|
public function setRequest(string $request): void |
85
|
|
|
{ |
86
|
|
|
$this->request = $request; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get request. |
91
|
|
|
*/ |
92
|
|
|
public function getRequest(): string |
93
|
|
|
{ |
94
|
|
|
return $this->request; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Set ip. |
99
|
|
|
*/ |
100
|
|
|
public function setIp(string $ip): void |
101
|
|
|
{ |
102
|
|
|
$this->ip = $ip; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Get ip. |
107
|
|
|
*/ |
108
|
|
|
public function getIp(): string |
109
|
|
|
{ |
110
|
|
|
return $this->ip; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* The data submitted when calling `_log()->info()`. |
115
|
|
|
*/ |
116
|
|
|
#[API\Exclude] |
117
|
|
|
public function getContext(): array |
118
|
|
|
{ |
119
|
|
|
return $this->context; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
#[API\Exclude] |
123
|
|
|
public function setContext(array $context): void |
124
|
|
|
{ |
125
|
|
|
$this->context = $context; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|