forked from flancer32/mage2_ext_bot_sess
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.php
More file actions
41 lines (35 loc) · 971 Bytes
/
Copy pathLogger.php
File metadata and controls
41 lines (35 loc) · 971 Bytes
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
41
<?php
/**
* Authors: Alex Gusev <alex@flancer64.com>
* Since: 2018
*/
namespace Flancer32\BotSess;
class Logger
extends \Monolog\Logger
{
const FILENAME = 'fl32.botsess.log';
const NAME = 'FL32BOTS';
public function __construct()
{
$handlers = $this->initHandlers();
$processors = [];
parent::__construct(static::NAME, $handlers, $processors);
}
private function initFormatter()
{
$dateFormat = "Y-m-d H:i:s";
$msgFormat = "%datetime%: %message%\n";
$result = new \Monolog\Formatter\LineFormatter($msgFormat, $dateFormat);
return $result;
}
private function initHandlers()
{
$result = [];
$path = BP . '/var/log/' . static::FILENAME;
$handler = new \Monolog\Handler\StreamHandler($path);
$formatter = $this->initFormatter();
$handler->setFormatter($formatter);
$result[] = $handler;
return $result;
}
}