Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Line | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| format | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | /** |
| 4 | * Pop PHP Framework (https://www.popphp.org/) |
| 5 | * |
| 6 | * @link https://github.com/popphp/popphp-framework |
| 7 | * @author Nick Sagona, III <dev@noladev.com> |
| 8 | * @copyright Copyright (c) 2009-2027 NOLA Interactive, LLC. |
| 9 | * @license https://www.popphp.org/license New BSD License |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * @namespace |
| 14 | */ |
| 15 | namespace Pop\Log\Formatter; |
| 16 | |
| 17 | use Pop\Log\Context; |
| 18 | |
| 19 | /** |
| 20 | * Plain tab-separated line formatter |
| 21 | * |
| 22 | * @category Pop |
| 23 | * @package Pop\Log |
| 24 | * @author Nick Sagona, III <dev@noladev.com> |
| 25 | * @copyright Copyright (c) 2009-2027 NOLA Interactive, LLC. |
| 26 | * @license https://www.popphp.org/license New BSD License |
| 27 | * @version 5.0.0 |
| 28 | */ |
| 29 | class Line implements FormatterInterface |
| 30 | { |
| 31 | |
| 32 | /** |
| 33 | * Format a single log entry into a tab-separated line |
| 34 | * |
| 35 | * @param string $level |
| 36 | * @param string $message |
| 37 | * @param array $context |
| 38 | * @return string |
| 39 | */ |
| 40 | public function format(string $level, string $message, array $context): string |
| 41 | { |
| 42 | return Context::sanitize($context['timestamp']) . "\t" . $level . "\t" . |
| 43 | Context::sanitize($context['name']) . "\t" . Context::sanitize($message) . "\t" . |
| 44 | Context::sanitize(Context::serialize($context)); |
| 45 | } |
| 46 | |
| 47 | } |