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)); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
private function modifyCotenxt(array $context) |
66
|
|
|
{ |
67
|
|
|
return array_merge_recursive($context, $this->extraContext); |
68
|
|
|
} |
69
|
|
|
} |