-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathDebugTool.php
More file actions
51 lines (45 loc) · 1.23 KB
/
DebugTool.php
File metadata and controls
51 lines (45 loc) · 1.23 KB
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
42
43
44
45
46
47
48
49
50
51
<?php
declare(strict_types=1);
namespace PHPJava\Utilities;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use PHPJava\Core\JVM\Parameters\GlobalOptions;
use PHPJava\Core\JVM\Parameters\Runtime;
class DebugTool
{
/**
* @var Logger
*/
private $logger;
/**
* @var array
*/
private $options = [];
public function __construct(string $channelName, array $options = [])
{
$this->logger = new Logger($channelName);
$this->options = $options;
$stream = new StreamHandler(
$this->options['log']['path'] ?? GlobalOptions::get('log.path') ?? Runtime::LOG_PATH,
$this->options['log']['level'] ?? GlobalOptions::get('log.level') ?? Runtime::LOG_LEVEL
);
$stream->setFormatter(
new LineFormatter(
null,
null,
true,
true
)
);
$this->logger->pushHandler($stream);
}
public function getLogLevel(): int
{
return $this->options['log']['level'] ?? GlobalOptions::get('log.level') ?? Runtime::LOG_LEVEL;
}
public function getLogger(): Logger
{
return $this->logger;
}
}