|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Quantum PHP Framework |
|
5
|
|
|
* |
|
6
|
|
|
* An open source software development framework for PHP |
|
7
|
|
|
* |
|
8
|
|
|
* @package Quantum |
|
9
|
|
|
* @author Arman Ag. <[email protected]> |
|
10
|
|
|
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) |
|
11
|
|
|
* @link http://quantum.softberg.org/ |
|
12
|
|
|
* @since 2.4.0 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Quantum\Logger; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
use Quantum\Contracts\ReportableInterface; |
|
19
|
|
|
use Quantum\Libraries\Storage\FileSystem; |
|
20
|
|
|
use Psr\Log\LoggerInterface; |
|
21
|
|
|
use Psr\Log\LogLevel; |
|
22
|
|
|
use Quantum\Di\Di; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Class Logger |
|
26
|
|
|
* @package Quantum\Logger |
|
27
|
|
|
*/ |
|
28
|
|
|
class Logger implements LoggerInterface |
|
29
|
|
|
{ |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var \Quantum\Contracts\ReportableInterface |
|
33
|
|
|
*/ |
|
34
|
|
|
private $reporter; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Logger constructor. |
|
38
|
|
|
* @param \Quantum\Contracts\ReportableInterface $reporter |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct(ReportableInterface $reporter) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->reporter = $reporter; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @inheritDoc |
|
47
|
|
|
*/ |
|
48
|
|
|
public function emergency($message, array $context = []) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->log(LogLevel::EMERGENCY, $message, $context); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @inheritDoc |
|
55
|
|
|
*/ |
|
56
|
|
|
public function alert($message, array $context = []) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->log(LogLevel::ALERT, $message, $context); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @inheritDoc |
|
63
|
|
|
*/ |
|
64
|
|
|
public function critical($message, array $context = []) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->log(LogLevel::CRITICAL, $message, $context); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @inheritDoc |
|
71
|
|
|
*/ |
|
72
|
|
|
public function error($message, array $context = []) |
|
73
|
|
|
{ |
|
74
|
|
|
$this->log(LogLevel::ERROR, $message, $context); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @inheritDoc |
|
79
|
|
|
*/ |
|
80
|
|
|
public function warning($message, array $context = []) |
|
81
|
|
|
{ |
|
82
|
|
|
$this->log(LogLevel::WARNING, $message, $context); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @inheritDoc |
|
87
|
|
|
*/ |
|
88
|
|
|
public function notice($message, array $context = []) |
|
89
|
|
|
{ |
|
90
|
|
|
$this->log(LogLevel::NOTICE, $message, $context); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @inheritDoc |
|
95
|
|
|
*/ |
|
96
|
|
|
public function info($message, array $context = []) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->log(LogLevel::INFO, $message, $context); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @inheritDoc |
|
103
|
|
|
*/ |
|
104
|
|
|
public function debug($message, array $context = []) |
|
105
|
|
|
{ |
|
106
|
|
|
$this->log(LogLevel::DEBUG, $message, $context); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @inheritDoc |
|
111
|
|
|
*/ |
|
112
|
|
|
public function log($level, $message, array $context = []) |
|
113
|
|
|
{ |
|
114
|
|
|
$this->reporter->report($level, $message, $context); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
} |