Skip to content

Commit 27278c7

Browse files
committed
Support - added Monolog 2.x handler.
1 parent fdc2b31 commit 27278c7

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

Clockwork/Support/Monolog/Handler/ClockworkHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Monolog\Handler\AbstractProcessingHandler;
77

88
// Stores messages in a Clockwork log instance
9+
// DEPRECATED Moved to Clockwork\Support\Monolog\Monolog\ClockworkHandler, will be removed in Clockwork 6
910
class ClockworkHandler extends AbstractProcessingHandler
1011
{
1112
protected $clockworkLog;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php namespace Clockwork\Support\Monolog\Monolog;
2+
3+
use Clockwork\Request\Log as ClockworkLog;
4+
5+
use Monolog\Logger;
6+
use Monolog\Handler\AbstractProcessingHandler;
7+
8+
// Stores messages in a Clockwork log instance (compatible with Monolog 1.x)
9+
class ClockworkHandler extends AbstractProcessingHandler
10+
{
11+
protected $clockworkLog;
12+
13+
public function __construct(ClockworkLog $clockworkLog)
14+
{
15+
parent::__construct();
16+
17+
$this->clockworkLog = $clockworkLog;
18+
}
19+
20+
protected function write(array $record)
21+
{
22+
$this->clockworkLog->log($record['level'], $record['message']);
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php namespace Clockwork\Support\Monolog\Monolog2;
2+
3+
use Clockwork\Request\Log as ClockworkLog;
4+
5+
use Monolog\Logger;
6+
use Monolog\Handler\AbstractProcessingHandler;
7+
8+
// Stores messages in a Clockwork log instance (compatible with Monolog 2.x)
9+
class ClockworkHandler extends AbstractProcessingHandler
10+
{
11+
protected $clockworkLog;
12+
13+
public function __construct(ClockworkLog $clockworkLog)
14+
{
15+
parent::__construct();
16+
17+
$this->clockworkLog = $clockworkLog;
18+
}
19+
20+
protected function write(array $record): void
21+
{
22+
$this->clockworkLog->log($record['level'], $record['message']);
23+
}
24+
}

0 commit comments

Comments
 (0)