1 | <?php |
||
12 | class Logger extends AbstractLogger |
||
13 | { |
||
14 | /** |
||
15 | * @var array $levels Conversion of the level strings to their numeric representations. |
||
16 | */ |
||
17 | private $levels = [ |
||
18 | LogLevel::EMERGENCY => 1, |
||
19 | LogLevel::ALERT => 2, |
||
20 | LogLevel::CRITICAL => 3, |
||
21 | LogLevel::ERROR => 4, |
||
22 | LogLevel::WARNING => 5, |
||
23 | LogLevel::NOTICE => 6, |
||
24 | LogLevel::INFO => 7, |
||
25 | LogLevel::DEBUG => 8, |
||
26 | ]; |
||
27 | |||
28 | /** |
||
29 | * @var int $level Ignore logging attempts at a level less than this. |
||
30 | */ |
||
31 | private $level; |
||
32 | |||
33 | /** |
||
34 | * @var CLImate $climate The underlying climate instance we are using for output. |
||
35 | */ |
||
36 | private $climate; |
||
37 | |||
38 | /** |
||
39 | * Create a new Logger instance. |
||
40 | * |
||
41 | * @param mixed $level Either a LogLevel constant, or a string (eg 'debug'), or a number (1-8) |
||
42 | * @param CLImate $climate An existing CLImate instance to use for output |
||
43 | */ |
||
44 | public function __construct($level = LogLevel::INFO, CLImate $climate = null) |
||
72 | |||
73 | |||
74 | /** |
||
75 | * Get a numeric log level for the passed parameter. |
||
76 | * |
||
77 | * @param mixed $level Either a LogLevel constant, or a string (eg 'debug'), or a number (1-8) |
||
78 | * |
||
79 | * @return int |
||
80 | */ |
||
81 | private function convertLevel($level) |
||
107 | |||
108 | |||
109 | /** |
||
110 | * Set the current level we are logging at. |
||
111 | * |
||
112 | * @param mixed $level Ignore logging attempts at a level less the $level |
||
113 | * |
||
114 | * @return static |
||
115 | */ |
||
116 | public function setLogLevel($level) |
||
122 | |||
123 | |||
124 | /** |
||
125 | * Log messages to a CLImate instance. |
||
126 | * |
||
127 | * @param mixed $level The level of the log message |
||
128 | * @param string|object $message If an object is passed it must implement __toString() |
||
129 | * @param array $context Placeholders to be substituted in the message |
||
130 | * |
||
131 | * @return static |
||
132 | */ |
||
133 | public function log($level, $message, array $context = []) |
||
162 | |||
163 | |||
164 | /** |
||
165 | * Handle recursive arrays in the logging context. |
||
166 | * |
||
167 | * @param mixed $level The level of the log message |
||
168 | * @param array $context The array of context to output |
||
169 | * @param int $indent The current level of indentation to be used |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | private function outputRecursiveContext($level, array $context, $indent) |
||
189 | } |
||
190 |