ConsoleLogger   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A log() 0 7 1
1
<?php
2
3
namespace Storeman\Cli;
4
5
use Psr\Log\LogLevel;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
class ConsoleLogger extends \Symfony\Component\Console\Logger\ConsoleLogger
9
{
10
    public function __construct(OutputInterface $output)
11
    {
12
        $formatLevelMap = [
13
            LogLevel::NOTICE => 'fg=default;bg=default',
14
            LogLevel::INFO => 'fg=white',
15
            LogLevel::DEBUG => 'fg=white',
16
        ];
17
18
        parent::__construct($output, [], $formatLevelMap);
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function log($level, $message, array $context = array())
25
    {
26
        $message = "[{now}] {$message}";
27
        $context += ['now' => new \DateTime()];
28
29
        parent::log($level, $message, $context);
30
    }
31
}
32