1 | <?php |
||
12 | class ElasticaLogger implements LoggerInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var LoggerInterface |
||
16 | */ |
||
17 | protected $logger; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $queries = array(); |
||
23 | |||
24 | /** |
||
25 | * @var boolean |
||
26 | */ |
||
27 | protected $debug; |
||
28 | |||
29 | /** |
||
30 | * Constructor. |
||
31 | * |
||
32 | * @param LoggerInterface|null $logger The Symfony logger |
||
33 | * @param boolean $debug |
||
34 | */ |
||
35 | 23 | public function __construct(LoggerInterface $logger = null, $debug = false) |
|
40 | |||
41 | /** |
||
42 | * Returns the number of queries that have been logged. |
||
43 | * |
||
44 | * @return integer The number of queries logged |
||
45 | */ |
||
46 | 3 | public function getNbQueries() |
|
50 | |||
51 | /** |
||
52 | * Returns a human-readable array of queries logged. |
||
53 | * |
||
54 | * @return array An array of queries |
||
55 | */ |
||
56 | 1 | public function getQueries() |
|
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 5 | public function debug($message, array $context = array()) |
|
65 | { |
||
66 | 5 | if ($this->debug) { |
|
67 | 2 | $this->queries[] = $context; |
|
68 | 2 | } |
|
69 | |||
70 | 5 | if (!$this->logger) { |
|
71 | 4 | return; |
|
72 | } |
||
73 | |||
74 | 1 | return $this->logger->debug($message, $context); |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | 2 | public function emergency($message, array $context = array()) |
|
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | 2 | public function alert($message, array $context = array()) |
|
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | 2 | public function critical($message, array $context = array()) |
|
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | 2 | public function error($message, array $context = array()) |
|
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | 2 | public function warning($message, array $context = array()) |
|
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | 2 | public function notice($message, array $context = array()) |
|
148 | |||
149 | /** |
||
150 | * {@inheritdoc} |
||
151 | */ |
||
152 | 2 | public function info($message, array $context = array()) |
|
160 | |||
161 | /** |
||
162 | * {@inheritdoc} |
||
163 | */ |
||
164 | 2 | public function log($level, $message, array $context = array()) |
|
172 | } |
||
173 |