-
Notifications
You must be signed in to change notification settings - Fork 0
/
DotLogger.php
40 lines (26 loc) · 987 Bytes
/
DotLogger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Dotslash\Utils;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Formatter\LineFormatter;
use Monolog\Processor\IntrospectionProcessor;
class DotLogger extends \Monolog\Logger {
private $logPath;
public function __construct($name, $logDirectory) {
$this->logPath = $logDirectory . '/' . $name;
parent::__construct($name);
$this->configureLogger();
}
private function configureLogger() {
$dateFormat = 'Y-m-d H:i:s';
$logFormat = "%datetime% %level_name% |[%codeInfo%] %message%\n";
$formatter = new LineFormatter($logFormat, $dateFormat);
$rotatingLogger = new RotatingFileHandler($this->logPath, 30);
$rotatingLogger->setFormatter($formatter);
$this->pushHandler($rotatingLogger);
$this->pushProcessor(new IntrospectionProcessor());
}
public function addRecord($level, $message, array $context = array()) {
return parent::addRecord($level, $message, $context);
}
}