1 | <?php |
||
35 | class Log |
||
36 | { |
||
37 | /** |
||
38 | * Pasta onde será salvo os arquivos de log |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | private $directory; |
||
43 | |||
44 | /** |
||
45 | * Processador de log |
||
46 | * |
||
47 | * @var \Monolog\Logger |
||
48 | */ |
||
49 | private $logger; |
||
50 | |||
51 | /** |
||
52 | * Instância salva para uso estático |
||
53 | * |
||
54 | * @var Log |
||
55 | */ |
||
56 | private static $instance; |
||
57 | |||
58 | /** |
||
59 | * Cria uma instância de Log |
||
60 | * @param array $log campos para preencher o log |
||
61 | */ |
||
62 | 2 | public function __construct($log = []) |
|
67 | |||
68 | /** |
||
69 | * Get current or create a new instance |
||
70 | * @return Log current instance |
||
71 | */ |
||
72 | 11 | public static function getInstance() |
|
79 | |||
80 | /** |
||
81 | * Pasta onde serão salvos os arquivos de Log |
||
82 | * @return string diretório atual onde os logs são salvos |
||
83 | */ |
||
84 | 12 | public function getDirectory() |
|
88 | |||
89 | /** |
||
90 | * Informa a nova pasta onde os logs serão salvos |
||
91 | * @param string $directory caminho absoluto da pasta |
||
92 | * @return Log a própria instência de Log |
||
93 | */ |
||
94 | 3 | public function setDirectory($directory) |
|
103 | |||
104 | /** |
||
105 | * Altera o gerenciador que escreve os logs, informe null para restaurar o padrão |
||
106 | * @param \Monolog\Handler\AbstractHandler $write_function nova função que será usada |
||
|
|||
107 | * @return Log a própria instência de Log |
||
108 | */ |
||
109 | 12 | public function setHandler($handler) |
|
118 | |||
119 | /** |
||
120 | * Converte a instância da classe para um array de campos com valores |
||
121 | * @param boolean $recursive informa se os campos devem ser convertidos para array |
||
122 | * @return array Array contendo todos os campos e valores da instância |
||
123 | */ |
||
124 | 1 | public function toArray($recursive = false) |
|
130 | |||
131 | /** |
||
132 | * Atribui os valores do array para a instância atual |
||
133 | * @param array|Log $log Array ou instância de Log, para copiar os valores |
||
134 | * @return Log A própria instância da classe |
||
135 | */ |
||
136 | 3 | public function fromArray($log = []) |
|
150 | |||
151 | /** |
||
152 | * Adds a log record at the ERROR level. |
||
153 | * |
||
154 | * This method allows for compatibility with common interfaces. |
||
155 | * |
||
156 | * @param string $message The log message |
||
157 | * @param array $context The log context |
||
158 | * @return Boolean Whether the record has been processed |
||
159 | */ |
||
160 | 4 | public static function error($message, $context = []) |
|
164 | |||
165 | /** |
||
166 | * Adds a log record at the WARNING level. |
||
167 | * |
||
168 | * This method allows for compatibility with common interfaces. |
||
169 | * |
||
170 | * @param string $message The log message |
||
171 | * @param array $context The log context |
||
172 | * @return Boolean Whether the record has been processed |
||
173 | */ |
||
174 | 2 | public static function warning($message, $context = []) |
|
178 | |||
179 | /** |
||
180 | * Adds a log record at the DEBUG level. |
||
181 | * |
||
182 | * This method allows for compatibility with common interfaces. |
||
183 | * |
||
184 | * @param string $message The log message |
||
185 | * @param array $context The log context |
||
186 | * @return Boolean Whether the record has been processed |
||
187 | */ |
||
188 | 2 | public static function debug($message, $context = []) |
|
192 | |||
193 | /** |
||
194 | * Adds a log record at the INFO level. |
||
195 | * |
||
196 | * This method allows for compatibility with common interfaces. |
||
197 | * |
||
198 | * @param string $message The log message |
||
199 | * @param array $context The log context |
||
200 | * @return Boolean Whether the record has been processed |
||
201 | */ |
||
202 | 1 | public static function info($message, $context = []) |
|
206 | } |
||
207 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.