1 | <?php |
||
34 | class DbHandler extends AbstractProcessingHandler |
||
35 | { |
||
36 | /** |
||
37 | * @var Db |
||
38 | */ |
||
39 | protected $db; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $table; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $additionalFields; |
||
50 | |||
51 | /** |
||
52 | * @var int |
||
53 | */ |
||
54 | protected $maxEntries; |
||
55 | |||
56 | /** |
||
57 | * @var int |
||
58 | */ |
||
59 | protected $cleanDivisor = 100; |
||
60 | |||
61 | /** |
||
62 | * Default probability of table being cleaned (1/100 = 1%). |
||
63 | * |
||
64 | * @var int |
||
65 | */ |
||
66 | protected $cleanProbability = 1; |
||
67 | |||
68 | /** |
||
69 | * @param Db $db |
||
70 | * @param int $maxEntries |
||
71 | * @param array $additionalFields |
||
72 | * @param int $level |
||
73 | * @param bool $bubble |
||
74 | * @param string $table |
||
75 | */ |
||
76 | 5 | public function __construct( |
|
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | 5 | protected function processRecord(array $record) |
|
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | */ |
||
115 | 5 | protected function write(array $record) |
|
127 | |||
128 | /** |
||
129 | * @param string $channel |
||
130 | */ |
||
131 | 5 | protected function clean($channel) |
|
141 | |||
142 | /** |
||
143 | * @param string $channel |
||
144 | * @return int |
||
145 | */ |
||
146 | 3 | protected function getChannelEntriesCount($channel) |
|
153 | |||
154 | /** |
||
155 | * @param $channel |
||
156 | * @param $entriesToDelete |
||
157 | */ |
||
158 | 1 | protected function deleteXOldestChannelEntries($channel, $entriesToDelete) |
|
169 | |||
170 | /** |
||
171 | * @param Logger $logger |
||
172 | */ |
||
173 | public function clear(Logger $logger) |
||
177 | |||
178 | /** |
||
179 | * {@inheritdoc} |
||
180 | */ |
||
181 | 5 | protected function getDefaultFormatter() |
|
185 | |||
186 | /** |
||
187 | * @see setCleanProbability() |
||
188 | * @param int $cleanDivisor |
||
189 | */ |
||
190 | 1 | public function setCleanDivisor($cleanDivisor) |
|
194 | |||
195 | /** |
||
196 | * Sets the probability that log table is cleaned on log write. |
||
197 | * |
||
198 | * The clean probability together with clean divisor is used to calculate the probability. |
||
199 | * With a clean probability of 1 and a divisor of 100, there's a 1% chance (1/100) the table |
||
200 | * will be cleaned. |
||
201 | * |
||
202 | * @param int $cleanProbability |
||
203 | */ |
||
204 | 3 | public function setCleanProbability($cleanProbability) |
|
208 | } |
||
209 |