1 | <?php |
||
38 | class HandlerWrapper implements ResetAwareHandlerInterface |
||
39 | { |
||
40 | |||
41 | /** |
||
42 | * The wrapped handler instance. |
||
43 | * |
||
44 | * @var \Monolog\Handler\HandlerInterface |
||
45 | */ |
||
46 | protected $handler; |
||
47 | |||
48 | /** |
||
49 | * The handler factory instance. |
||
50 | * |
||
51 | * @var \TechDivision\Import\Loggers\HandlerFactoryInterface |
||
52 | */ |
||
53 | protected $handlerFactory; |
||
54 | |||
55 | /** |
||
56 | * The handler configuration instance. |
||
57 | * |
||
58 | * @var \TechDivision\Import\Configuration\Logger\HandlerConfigurationInterface |
||
59 | */ |
||
60 | protected $handlerConfiguration; |
||
61 | |||
62 | /** |
||
63 | * Initializes the wrapper with the handler instance. |
||
64 | * |
||
65 | * @param \TechDivision\Import\Loggers\HandlerFactoryInterface $handlerFactory The handler factory instance |
||
66 | * @param \TechDivision\Import\Configuration\Logger\HandlerConfigurationInterface $handlerConfiguration The handler configuration instance |
||
67 | */ |
||
68 | public function __construct(HandlerFactoryInterface $handlerFactory, HandlerConfigurationInterface $handlerConfiguration) |
||
78 | |||
79 | /** |
||
80 | * Reset's the handler instance. |
||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | public function reset() |
||
103 | |||
104 | /** |
||
105 | * Checks whether the given record will be handled by this handler. |
||
106 | * |
||
107 | * This is mostly done for performance reasons, to avoid calling processors for nothing. |
||
108 | * |
||
109 | * Handlers should still check the record levels within handle(), returning false in isHandling() |
||
110 | * is no guarantee that handle() will not be called, and isHandling() might not be called |
||
111 | * for a given record. |
||
112 | * |
||
113 | * @param array $record Partial log record containing only a level key |
||
114 | * |
||
115 | * @return boolean TRUE if the handler has to handle the record, FALSE otherwise |
||
116 | */ |
||
117 | public function isHandling(array $record) |
||
121 | |||
122 | /** |
||
123 | * Handles a record. |
||
124 | * |
||
125 | * All records may be passed to this method, and the handler should discard |
||
126 | * those that it does not want to handle. |
||
127 | * |
||
128 | * The return value of this function controls the bubbling process of the handler stack. |
||
129 | * Unless the bubbling is interrupted (by returning true), the Logger class will keep on |
||
130 | * calling further handlers in the stack with a given log record. |
||
131 | * |
||
132 | * @param array $record The record to handle |
||
133 | * |
||
134 | * @return boolean TRUE means that this handler handled the record, and that bubbling is not permitted. |
||
135 | * FALSE means the record was either not processed or that this handler allows bubbling. |
||
136 | */ |
||
137 | public function handle(array $record) |
||
141 | |||
142 | /** |
||
143 | * Handles a set of records at once. |
||
144 | * |
||
145 | * @param array $records The records to handle (an array of record arrays) |
||
146 | * |
||
147 | * @return void |
||
148 | */ |
||
149 | public function handleBatch(array $records) |
||
153 | |||
154 | /** |
||
155 | * Return's the handlers formatter instance. |
||
156 | * |
||
157 | * @return \Monolog\Formatter\FormatterInterface The formatter instance |
||
158 | */ |
||
159 | public function getFormatter() |
||
163 | |||
164 | /** |
||
165 | * Adds a processor in the stack. |
||
166 | * |
||
167 | * @param callable $callback The processor to add |
||
168 | * |
||
169 | * @return \TechDivision\Import\Loggers\Handlers\HandlerWrapper The handler instance |
||
170 | */ |
||
171 | public function pushProcessor($callback) |
||
176 | |||
177 | /** |
||
178 | * Removes the processor on top of the stack and returns it. |
||
179 | * |
||
180 | * @return \TechDivision\Import\Loggers\Handlers\HandlerWrapper The handler instance |
||
181 | */ |
||
182 | public function popProcessor() |
||
187 | |||
188 | /** |
||
189 | * Sets the handler's formatter instance. |
||
190 | * |
||
191 | * @param \Monolog\Formatter\FormatterInterface $formatter The formatter instance |
||
192 | * |
||
193 | * @return \TechDivision\Import\Loggers\Handlers\HandlerWrapper The handler instance |
||
194 | */ |
||
195 | public function setFormatter(FormatterInterface $formatter) |
||
200 | } |
||
201 |