Skip to content

Commit c0e16a9

Browse files
authored
Merge pull request #50 from jbroadway/Multiple-loggers
Delay setting the handler in Logger so each Logger can have its own handler
2 parents 5955293 + 831f8a2 commit c0e16a9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/Analog/Logger.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
* @author Johnny Broadway
5353
*/
5454
class Logger implements LoggerInterface {
55+
private $handler = null;
56+
5557
/**
5658
* Converts from PSR-3 log levels to Analog log levels.
5759
*/
@@ -130,7 +132,7 @@ private function interpolate ($message, array $context = array ()) {
130132
* Sets the Analog log handler.
131133
*/
132134
public function handler ($handler) {
133-
Analog::handler ($handler);
135+
$this->handler = $handler;
134136
}
135137

136138
/**
@@ -212,6 +214,10 @@ public function log ($level, $message, array $context = array ()) {
212214
* Perform the logging to Analog after the log level has been converted.
213215
*/
214216
private function _log ($level, $message, $context) {
217+
if ($this->handler != null) {
218+
Analog::handler ($this->handler);
219+
}
220+
215221
Analog::log (
216222
$this->interpolate ($message, $context),
217223
$level

0 commit comments

Comments
 (0)