@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $command->bindValue(':category', $log[TLogger::LOG_CATEGORY]); |
127 | 127 | $command->bindValue(':prefix', $this->getLogPrefix($log)); |
128 | 128 | $command->bindValue(':logtime', sprintf('%F', $log[TLogger::LOG_TIME])); |
129 | - if(!$command->execute()) { |
|
129 | + if (!$command->execute()) { |
|
130 | 130 | throw new TLogException('dblogroute_insert_failed', $this->_logTable); |
131 | 131 | } |
132 | 132 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @return string The where clause for the various SQL statements. |
147 | 147 | * @since 4.2.3 |
148 | 148 | */ |
149 | - protected function getLogWhere(?int $level, null|string|array $categories, ?float $minTime, ?float $maxTime, &$values): string |
|
149 | + protected function getLogWhere(?int $level, null | string | array $categories, ?float $minTime, ?float $maxTime, &$values): string |
|
150 | 150 | { |
151 | 151 | $where = ''; |
152 | 152 | $values = []; |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | $values[':level'] = $level; |
156 | 156 | } |
157 | 157 | if ($categories !== null) { |
158 | - if(is_string($categories)) { |
|
158 | + if (is_string($categories)) { |
|
159 | 159 | $categories = array_map('trim', explode(',', $categories)); |
160 | 160 | } |
161 | 161 | $i = 0; |
162 | 162 | $or = ''; |
163 | - foreach($categories as $category) { |
|
163 | + foreach ($categories as $category) { |
|
164 | 164 | $c = $category[0] ?? 0; |
165 | 165 | if ($c === '!' || $c === '~') { |
166 | 166 | if ($where) { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @return string The where clause for the various SQL statements.. |
215 | 215 | * @since 4.2.3 |
216 | 216 | */ |
217 | - public function getDBLogCount(?int $level = null, null|string|array $categories = null, ?float $minTime = null, ?float $maxTime = null) |
|
217 | + public function getDBLogCount(?int $level = null, null | string | array $categories = null, ?float $minTime = null, ?float $maxTime = null) |
|
218 | 218 | { |
219 | 219 | $values = []; |
220 | 220 | $where = $this->getLogWhere($level, $categories, $minTime, $maxTime, $values); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @return \Prado\Data\TDbDataReader the logs from the database. |
239 | 239 | * @since 4.2.3 |
240 | 240 | */ |
241 | - public function getDBLogs(?int $level = null, null|string|array $categories = null, ?float $minTime = null, ?float $maxTime = null, string $order = '', string $limit = '') |
|
241 | + public function getDBLogs(?int $level = null, null | string | array $categories = null, ?float $minTime = null, ?float $maxTime = null, string $order = '', string $limit = '') |
|
242 | 242 | { |
243 | 243 | $values = []; |
244 | 244 | if ($order) { |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @return int the number of logs in the database. |
267 | 267 | * @since 4.2.3 |
268 | 268 | */ |
269 | - public function deleteDBLog(?int $level = null, null|string|array $categories = null, ?float $minTime = null, ?float $maxTime = null) |
|
269 | + public function deleteDBLog(?int $level = null, null | string | array $categories = null, ?float $minTime = null, ?float $maxTime = null) |
|
270 | 270 | { |
271 | 271 | $values = []; |
272 | 272 | $where = $this->getLogWhere($level, $categories, $minTime, $maxTime, $values); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @var false|string The Prefix for openlog() |
31 | 31 | */ |
32 | - private string|false $_sysLogPrefix = false; |
|
32 | + private string | false $_sysLogPrefix = false; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @var ?int The flags for openlog(), default null for `LOG_ODELAY | LOG_PID` |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * @return string The prefix for syslog. Defaults to false |
93 | 93 | */ |
94 | - public function getSysLogPrefix(): string|false |
|
94 | + public function getSysLogPrefix(): string | false |
|
95 | 95 | { |
96 | 96 | return $this->_sysLogPrefix; |
97 | 97 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | ]; |
137 | 137 | |
138 | 138 | if ($value === null || is_int($value)) { |
139 | - $invalidFlags = ~array_reduce($_flagsMap, function ($flags, $flag) { |
|
139 | + $invalidFlags = ~array_reduce($_flagsMap, function($flags, $flag) { |
|
140 | 140 | return $flags | $flag; |
141 | 141 | }, 0); |
142 | 142 | if ($invalidFlags & ((int) $value)) { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | $options = array_map('trim', $value); |
153 | 153 | $this->_sysLogFlags = 0; |
154 | - while(count($options)) { |
|
154 | + while (count($options)) { |
|
155 | 155 | $option = array_pop($options); |
156 | 156 | if (isset($_flagsMap[$option])) { |
157 | 157 | $this->_sysLogFlags |= $_flagsMap[$option]; |
@@ -176,24 +176,24 @@ discard block |
||
176 | 176 | public function setFacility($value): static |
177 | 177 | { |
178 | 178 | static $_facilitiesMap = [ |
179 | - 'LOG_AUTH' => LOG_AUTH, // 0x20 |
|
180 | - 'LOG_CRON' => LOG_CRON, // 0x48 |
|
181 | - 'LOG_DAEMON' => LOG_DAEMON, // 0x18 |
|
182 | - 'LOG_KERN' => LOG_KERN, // 0x00 |
|
183 | - 'LOG_LOCAL0' => LOG_LOCAL0, // 0x80 |
|
184 | - 'LOG_LOCAL1' => LOG_LOCAL1, // 0x88 |
|
185 | - 'LOG_LOCAL2' => LOG_LOCAL2, // 0x90 |
|
186 | - 'LOG_LOCAL3' => LOG_LOCAL3, // 0x98 |
|
187 | - 'LOG_LOCAL4' => LOG_LOCAL4, // 0xa0 |
|
188 | - 'LOG_LOCAL5' => LOG_LOCAL5, // 0xa8 |
|
189 | - 'LOG_LOCAL6' => LOG_LOCAL6, // 0xb0 |
|
190 | - 'LOG_LOCAL7' => LOG_LOCAL7, // 0xb8 |
|
191 | - 'LOG_LPR' => LOG_LPR, // 0x30 |
|
192 | - 'LOG_MAIL' => LOG_MAIL, // 0x10 |
|
193 | - 'LOG_NEWS' => LOG_NEWS, // 0x38 |
|
179 | + 'LOG_AUTH' => LOG_AUTH, // 0x20 |
|
180 | + 'LOG_CRON' => LOG_CRON, // 0x48 |
|
181 | + 'LOG_DAEMON' => LOG_DAEMON, // 0x18 |
|
182 | + 'LOG_KERN' => LOG_KERN, // 0x00 |
|
183 | + 'LOG_LOCAL0' => LOG_LOCAL0, // 0x80 |
|
184 | + 'LOG_LOCAL1' => LOG_LOCAL1, // 0x88 |
|
185 | + 'LOG_LOCAL2' => LOG_LOCAL2, // 0x90 |
|
186 | + 'LOG_LOCAL3' => LOG_LOCAL3, // 0x98 |
|
187 | + 'LOG_LOCAL4' => LOG_LOCAL4, // 0xa0 |
|
188 | + 'LOG_LOCAL5' => LOG_LOCAL5, // 0xa8 |
|
189 | + 'LOG_LOCAL6' => LOG_LOCAL6, // 0xb0 |
|
190 | + 'LOG_LOCAL7' => LOG_LOCAL7, // 0xb8 |
|
191 | + 'LOG_LPR' => LOG_LPR, // 0x30 |
|
192 | + 'LOG_MAIL' => LOG_MAIL, // 0x10 |
|
193 | + 'LOG_NEWS' => LOG_NEWS, // 0x38 |
|
194 | 194 | 'LOG_SYSLOG' => LOG_SYSLOG, // 0x28 |
195 | - 'LOG_USER' => LOG_USER, // 0x08 |
|
196 | - 'LOG_UUCP' => LOG_UUCP, // 0x40 |
|
195 | + 'LOG_USER' => LOG_USER, // 0x08 |
|
196 | + 'LOG_UUCP' => LOG_UUCP, // 0x40 |
|
197 | 197 | ]; |
198 | 198 | if (defined('LOG_AUTHPRIV')) { |
199 | 199 | $_facilitiesMap['LOG_AUTH'] = LOG_AUTHPRIV; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | public function setLevels($levels): static |
150 | 150 | { |
151 | 151 | if (is_int($levels)) { |
152 | - $invalidLevels = ~array_reduce(static::$_levelValues, function ($levels, $level) { |
|
152 | + $invalidLevels = ~array_reduce(static::$_levelValues, function($levels, $level) { |
|
153 | 153 | return $levels | $level; |
154 | 154 | }, 0); |
155 | 155 | if ($invalidLevels & $levels) { |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $next = []; |
445 | 445 | $nextNext = []; |
446 | 446 | |
447 | - foreach(array_reverse(array_keys($logs)) as $key) { |
|
447 | + foreach (array_reverse(array_keys($logs)) as $key) { |
|
448 | 448 | $next[$key] = $nextNext[$logs[$key][TLogger::LOG_PID]] ?? null; |
449 | 449 | $nextNext[$logs[$key][TLogger::LOG_PID]] = $key; |
450 | 450 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $profileLast = []; |
455 | 455 | $profileTotal = []; |
456 | 456 | $startTime = $_SERVER["REQUEST_TIME_FLOAT"]; |
457 | - foreach(array_keys($logs) as $key) { |
|
457 | + foreach (array_keys($logs) as $key) { |
|
458 | 458 | if (isset($next[$key])) { |
459 | 459 | $logs[$key]['delta'] = $logs[$next[$key]][TLogger::LOG_TIME] - $logs[$key][TLogger::LOG_TIME]; |
460 | 460 | $total = $logs[$key]['total'] = $logs[$key][TLogger::LOG_TIME] - $startTime; |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | if ($total > $this->_totalTime) { |
466 | 466 | $this->_totalTime = $total; |
467 | 467 | } |
468 | - if(($logs[$key][TLogger::LOG_LEVEL] & TLogger::PROFILE_BEGIN) === TLogger::PROFILE_BEGIN) { |
|
468 | + if (($logs[$key][TLogger::LOG_LEVEL] & TLogger::PROFILE_BEGIN) === TLogger::PROFILE_BEGIN) { |
|
469 | 469 | $profileToken = $logs[$key][TLogger::LOG_MESSAGE] . $logs[$key][TLogger::LOG_PID]; |
470 | 470 | $profile[$profileToken] = $logs[$key]; |
471 | 471 | $profileLast[$profileToken] = false; |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | $logs[$key]['total'] = 0; |
475 | 475 | $logs[$key][TLogger::LOG_MESSAGE] = 'Profile Begin: ' . $logs[$key][TLogger::LOG_MESSAGE]; |
476 | 476 | |
477 | - } elseif(($logs[$key][TLogger::LOG_LEVEL] & TLogger::PROFILE_END) === TLogger::PROFILE_END) { |
|
477 | + } elseif (($logs[$key][TLogger::LOG_LEVEL] & TLogger::PROFILE_END) === TLogger::PROFILE_END) { |
|
478 | 478 | $profileToken = $logs[$key][TLogger::LOG_MESSAGE] . $logs[$key][TLogger::LOG_PID]; |
479 | 479 | if (isset($profile[$profileToken])) { |
480 | 480 | if ($profileLast[$profileToken] !== false) { |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @param TLogger $logger logger instance |
502 | 502 | * @param bool $final is the final collection of logs |
503 | 503 | */ |
504 | - public function collectLogs(null|bool|TLogger $logger = null, bool $final = false) |
|
504 | + public function collectLogs(null | bool | TLogger $logger = null, bool $final = false) |
|
505 | 505 | { |
506 | 506 | if (is_bool($logger)) { |
507 | 507 | $final = $logger; |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | $final |= $this instanceof IOutputLogRoute; |
517 | 517 | if ($count > 0 && ($final || $this->_processInterval > 0 && $count >= $this->_processInterval)) { |
518 | 518 | $logs = $this->_logs; |
519 | - $meta = ['maxdelta' => $this->_maxDelta, 'total' => $this->_totalTime] ; |
|
519 | + $meta = ['maxdelta' => $this->_maxDelta, 'total' => $this->_totalTime]; |
|
520 | 520 | $this->_logs = []; |
521 | 521 | $this->_maxDelta = 0; |
522 | 522 | $this->_totalTime = 0; |
@@ -191,7 +191,7 @@ |
||
191 | 191 | $weightLightCutOff = 0.4; |
192 | 192 | if ($normalizedTime > $weightCutOff) { |
193 | 193 | $weight = '; font-weight: ' . round(400 + 500 * ($normalizedTime - $weightCutOff) / (1 - $weightCutOff)); |
194 | - } elseif($normalizedTime < $weightLightCutOff) { |
|
194 | + } elseif ($normalizedTime < $weightLightCutOff) { |
|
195 | 195 | $weight = '; font-weight: ' . round(400 - 300 * ($weightLightCutOff - $normalizedTime) / ($weightLightCutOff)); |
196 | 196 | } else { |
197 | 197 | $weight = ''; |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function __construct(bool $flushShutdown = true) |
144 | 144 | { |
145 | - if($flushShutdown) { |
|
146 | - register_shutdown_function(function () { |
|
145 | + if ($flushShutdown) { |
|
146 | + register_shutdown_function(function() { |
|
147 | 147 | $this->onFlushLogs(); |
148 | 148 | // flush any logs in the shutdown function. |
149 | 149 | register_shutdown_function([$this, 'onFlushLogs'], $this, true); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @return int The number of logs. |
215 | 215 | * @since 4.2.3 |
216 | 216 | */ |
217 | - public function getLogCount(null|bool|int $selector = null): int |
|
217 | + public function getLogCount(null | bool | int $selector = null): int |
|
218 | 218 | { |
219 | 219 | if ($selector === null) {// logs @TLogRoute::processLogs after removing logged elements. |
220 | 220 | return count($this->_logs) + $this->_profileLogsCount; |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | return; |
400 | 400 | } |
401 | 401 | |
402 | - if(is_bool($sender)) { |
|
402 | + if (is_bool($sender)) { |
|
403 | 403 | $final = $sender; |
404 | 404 | $sender = null; |
405 | 405 | } |
@@ -416,14 +416,14 @@ discard block |
||
416 | 416 | $this->deleteLogs(); |
417 | 417 | $this->_flushing = false; |
418 | 418 | if (count($this->_flushingLog)) { |
419 | - foreach($this->_flushingLog as $log) { |
|
419 | + foreach ($this->_flushingLog as $log) { |
|
420 | 420 | $this->addLog($log, false); // $final = false to stop any possible recursion w/ low flushCount. |
421 | 421 | } |
422 | 422 | } |
423 | 423 | $this->_flushingLog = null; |
424 | 424 | |
425 | 425 | $this->_profileLogsCount = 0; |
426 | - foreach(array_keys($this->_profileLogs) as $key) { |
|
426 | + foreach (array_keys($this->_profileLogs) as $key) { |
|
427 | 427 | $this->_profileLogs[$key][static::LOG_LEVEL] |= static::LOGGED; |
428 | 428 | } |
429 | 429 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | * [6] => traces, when configured; null when absent |
467 | 467 | * [7] => process id) |
468 | 468 | */ |
469 | - public function getLogs(?int $levels = null, null|array|string $categories = null, null|array|string $controls = null, null|int|float $timestamp = null, ?int $pid = null) |
|
469 | + public function getLogs(?int $levels = null, null | array | string $categories = null, null | array | string $controls = null, null | int | float $timestamp = null, ?int $pid = null) |
|
470 | 470 | { |
471 | 471 | $this->_levels = $levels; |
472 | 472 | if (!empty($categories) && !is_array($categories)) { |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | public function mergeLogs(array $logs) |
516 | 516 | { |
517 | 517 | $count = count($logs); |
518 | - foreach($logs as $log) { |
|
518 | + foreach ($logs as $log) { |
|
519 | 519 | $log[static::LOG_LEVEL] &= ~TLogger::LOGGED; |
520 | 520 | $this->addLog($log, !(--$count)); |
521 | 521 | } |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | * @param ?int $pid |
549 | 549 | * @return array The logs being delete are returned. |
550 | 550 | */ |
551 | - public function deleteLogs(?int $levels = null, null|string|array $categories = null, null|string|array $controls = null, null|int|float $timestamp = null, ?int $pid = null): array |
|
551 | + public function deleteLogs(?int $levels = null, null | string | array $categories = null, null | string | array $controls = null, null | int | float $timestamp = null, ?int $pid = null): array |
|
552 | 552 | { |
553 | 553 | $this->_levels = $levels; |
554 | 554 | if (!empty($categories) && !is_array($categories)) { |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | } |
633 | 633 | $c = $category[0] ?? 0; |
634 | 634 | if ($c === '!' || $c === '~') { |
635 | - if(!$exclude) { |
|
635 | + if (!$exclude) { |
|
636 | 636 | $category = substr($category, 1); |
637 | 637 | if ($log[static::LOG_CATEGORY] === $category || str_ends_with($category, '*') && strpos($log[static::LOG_CATEGORY], rtrim($category, '*')) === 0) { |
638 | 638 | $exclude = true; |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | } |
690 | 690 | $c = $control[0] ?? 0; |
691 | 691 | if ($c === '!' || $c === '~') { |
692 | - if(!$exclude) { |
|
692 | + if (!$exclude) { |
|
693 | 693 | $control = substr($control, 1); |
694 | 694 | if ($log[static::LOG_CONTROL] === $control || str_ends_with($control, '*') && strpos($log[static::LOG_CONTROL], rtrim($control, '*')) === 0) { |
695 | 695 | $exclude = true; |