ConsoleFormatter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 24
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 17 4
1
<?php
2
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CacheTool\Monolog;
13
14
use Monolog\Formatter\LineFormatter;
15
use Monolog\Logger;
16
17
/**
18
 * Formats incoming records for console output by coloring them depending on log level.
19
 *
20
 * @author Tobias Schultze <http://tobion.de>
21
 */
22
class ConsoleFormatter extends LineFormatter
23
{
24
    const SIMPLE_FORMAT = "%start_tag%[%datetime%] %channel%.%level_name%:%end_tag% %message% %context% %extra%\n";
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 20
    public function format(array $record): string
30
    {
31 20
        if ($record['level'] >= Logger::ERROR) {
32 6
            $record['start_tag'] = '<error>';
33 6
            $record['end_tag'] = '</error>';
34 17
        } elseif ($record['level'] >= Logger::NOTICE) {
35 14
            $record['start_tag'] = '<comment>';
36 14
            $record['end_tag'] = '</comment>';
37 5
        } elseif ($record['level'] >= Logger::INFO) {
38 5
            $record['start_tag'] = '<info>';
39 5
            $record['end_tag'] = '</info>';
40
        } else {
41 5
            $record['start_tag'] = '';
42 5
            $record['end_tag'] = '';
43
        }
44
45 20
        return parent::format($record);
46
    }
47
}
48