44
55namespace Yiisoft \Log ;
66
7- use DateTime ;
8- use Psr \Log \InvalidArgumentException ;
9- use Psr \Log \LogLevel ;
10- use Yiisoft \Arrays \ArrayHelper ;
11- use Yiisoft \VarDumper \VarDumper ;
12-
137use function array_merge ;
148use function count ;
9+ use DateTime ;
1510use function implode ;
1611use function in_array ;
12+
1713use function is_array ;
1814use function is_callable ;
1915use function is_string ;
16+ use Psr \Log \InvalidArgumentException ;
17+ use Psr \Log \LogLevel ;
2018use function rtrim ;
2119use function strpos ;
2220use function substr_compare ;
21+ use Yiisoft \Arrays \ArrayHelper ;
22+ use Yiisoft \VarDumper \VarDumper ;
2323
2424/**
2525 * Target is the base class for all log target classes.
@@ -58,6 +58,7 @@ abstract class Target
5858 * You can use an asterisk at the end of a category so that the category can be used to
5959 * match those categories sharing the same common prefix. For example, 'Yiisoft\Db\*' will match
6060 * categories starting with 'Yiisoft\Db\', such as `Yiisoft\Db\Connection`.
61+ *
6162 * @see categories
6263 */
6364 private array $ except = [];
@@ -143,6 +144,7 @@ abstract public function export(): void;
143144 * Processes the given log messages.
144145 * This method will filter the given messages with {@see Target::$levels} and {@see Target::$categories}.
145146 * And if requested, it will also export the filtering result to specific medium (e.g. email).
147+ *
146148 * @param array $messages log messages to be processed. See {@see Logger::$messages} for the structure
147149 * of each message.
148150 * @param bool $final whether this method is called at the end of the current application
@@ -162,8 +164,8 @@ public function collect(array $messages, bool $final): void
162164 $ context ,
163165 [
164166 'category ' => static ::DEFAULT_CATEGORY ,
165- 'time ' => $ _SERVER ['REQUEST_TIME_FLOAT ' ] ?? \microtime (true )
166- ]
167+ 'time ' => $ _SERVER ['REQUEST_TIME_FLOAT ' ] ?? \microtime (true ),
168+ ],
167169 ];
168170 }
169171 // set exportInterval to 0 to avoid triggering export again while exporting
@@ -179,6 +181,7 @@ public function collect(array $messages, bool $final): void
179181 /**
180182 * Generates the context information to be logged.
181183 * The default implementation will dump user information, system variables, etc.
184+ *
182185 * @return string the context information. If an empty string, it means no context information.
183186 */
184187 protected function getContextMessage (): string
@@ -194,12 +197,15 @@ protected function getContextMessage(): string
194197
195198 /**
196199 * Filters the given messages according to their categories and levels.
200+ *
197201 * @param array $messages messages to be filtered. The message structure follows that in {@see Logger::$messages}.
198202 * @param array $levels the message levels to filter by. Empty value means allowing all levels.
199203 * @param array $categories the message categories to filter by. If empty, it means all categories are allowed.
200204 * @param array $except the message categories to exclude. If empty, it means all categories are allowed.
201- * @return array the filtered messages.
205+ *
202206 * @throws InvalidArgumentException for invalid message structure.
207+ *
208+ * @return array the filtered messages.
203209 */
204210 protected function filterMessages (
205211 array $ messages ,
@@ -255,7 +261,9 @@ protected function filterMessages(
255261
256262 /**
257263 * Checks message structure {@see Logger::$messages}.
264+ *
258265 * @param mixed $message the log message to be checked.
266+ *
259267 * @throws InvalidArgumentException for invalid message structure.
260268 */
261269 protected function checkMessageStructure ($ message ): void
@@ -267,10 +275,13 @@ protected function checkMessageStructure($message): void
267275
268276 /**
269277 * Formats a log message for display as a string.
278+ *
270279 * @param array $message the log message to be formatted.
271280 * The message structure follows that in {@see Logger::$messages}.
272- * @return string the formatted message.
281+ *
273282 * @throws InvalidArgumentException for invalid message structure.
283+ *
284+ * @return string the formatted message.
274285 */
275286 protected function formatMessage (array $ message ): string
276287 {
@@ -300,8 +311,10 @@ protected function formatMessage(array $message): string
300311 * Returns a string to be prefixed to the given message.
301312 * If {@see Target::$prefix} is configured it will return the result of the callback.
302313 * The default implementation will return user IP, user ID and session ID as a prefix.
314+ *
303315 * @param array $message the message being exported.
304316 * The message structure follows that in {@see Logger::$messages}.
317+ *
305318 * @return string the prefix string
306319 */
307320 protected function getMessagePrefix (array $ message ): string
@@ -315,7 +328,9 @@ protected function getMessagePrefix(array $message): string
315328
316329 /**
317330 * Returns formatted timestamp for message, according to {@see Target::$timestampFormat}
331+ *
318332 * @param float|int $timestamp
333+ *
319334 * @return string
320335 */
321336 protected function getTime ($ timestamp ): string
@@ -327,6 +342,7 @@ protected function getTime($timestamp): string
327342
328343 /**
329344 * Sets a value indicating whether this log target is enabled.
345+ *
330346 * @param bool|callable $value a boolean value or a callable to obtain the value from.
331347 *
332348 * A callable may be used to determine whether the log target should be enabled in a dynamic way.
@@ -338,6 +354,7 @@ protected function getTime($timestamp): string
338354 * return !Yii::getApp()->user->isGuest;
339355 * }
340356 * ```
357+ *
341358 * @return $this
342359 */
343360 public function setEnabled ($ value ): self
@@ -369,6 +386,7 @@ public function disable(): self
369386
370387 /**
371388 * Check whether the log target is enabled.
389+ *
372390 * @return bool A value indicating whether this log target is enabled.
373391 */
374392 public function isEnabled (): bool
0 commit comments