Skip to content

Commit 973919f

Browse files
authored
Merge pull request #682 from DominicDetta/monolog2-handler
fix(#676): allow monolog datasource to set the correct handler
2 parents adb0209 + f0a0d21 commit 973919f

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

Clockwork/DataSource/MonologDataSource.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use Clockwork\DataSource\DataSource;
44
use Clockwork\Request\Log;
55
use Clockwork\Request\Request;
6-
use Clockwork\Support\Monolog\Handler\ClockworkHandler;
7-
6+
use Clockwork\Support\Monolog\Monolog2\ClockworkHandler as Monolog2ClockworkHandler;
7+
use Clockwork\Support\Monolog\Monolog\ClockworkHandler;
88
use Monolog\Logger as Monolog;
99

1010
// Data source for Monolog, provides application log
@@ -18,7 +18,21 @@ public function __construct(Monolog $monolog)
1818
{
1919
$this->log = new Log;
2020

21-
$monolog->pushHandler(new ClockworkHandler($this->log));
21+
$handler=null;
22+
switch (\Monolog\Logger::API) {
23+
case 1:
24+
$handler=new ClockworkHandler($this->log);
25+
break;
26+
case 2:
27+
$handler=new Monolog2ClockworkHandler($this->log);
28+
break;
29+
default:
30+
// By default use the latest implementation of clockwork handler
31+
$handler=new Monolog2ClockworkHandler($this->log);
32+
break;
33+
}
34+
35+
$monolog->pushHandler($handler);
2236
}
2337

2438
// Adds log entries to the request

0 commit comments

Comments
 (0)