Completed
Pull Request — master (#39)
by Aleksandr
06:46
created

ExtraContextLogger::alert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace OldSound\RabbitMqBundle\Logger;
4
5
use Psr\Log\LoggerInterface;
6
7
class ExtraContextLogger implements LoggerInterface
8
{
9
    /** @var LoggerInterface */
10
    private $origin;
11
    /** @var array */
12
    private $extraContext;
13
14
    public function __constract(LoggerInterface $origin, array $extraContext)
15
    {
16
        $this->origin = $origin;
17
        $this->extraContext = $extraContext;
18
    }
19
20
    public function emergency($message, array $context = array())
21
    {
22
        $this->origin->emergency($message, $this->modifyCotenxt($context));
23
    }
24
25
    public function alert($message, array $context = array())
26
    {
27
        $this->origin->alert($message, $this->modifyCotenxt($context));
28
    }
29
30
    public function critical($message, array $context = array())
31
    {
32
        $this->origin->critical($message, $this->modifyCotenxt($context));
33
    }
34
35
    public function error($message, array $context = array())
36
    {
37
        $this->origin->error($message, $this->modifyCotenxt($context));
38
    }
39
40
    public function warning($message, array $context = array())
41
    {
42
        $this->origin->warning($message, $this->modifyCotenxt($context));
43
    }
44
45
    public function notice($message, array $context = array())
46
    {
47
        $this->origin->notice($message, $this->modifyCotenxt($context));
48
    }
49
50
    public function info($message, array $context = array())
51
    {
52
        $this->origin->info($message, $this->modifyCotenxt($context));
53
    }
54
55
    public function debug($message, array $context = array())
56
    {
57
        $this->origin->debug($message, $this->modifyCotenxt($context));
58
    }
59
60
    public function log($level, $message, array $context = array())
61
    {
62
        $this->origin->log($message, $this->modifyCotenxt($context));
0 ignored issues
show
Bug introduced by
$this->modifyCotenxt($context) of type array is incompatible with the type string expected by parameter $message of Psr\Log\LoggerInterface::log(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

62
        $this->origin->log($message, /** @scrutinizer ignore-type */ $this->modifyCotenxt($context));
Loading history...
63
    }
64
65
    private function modifyCotenxt(array $context)
66
    {
67
        return array_merge_recursive($context, $this->extraContext);
68
    }
69
}