1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Micro framework package. |
5
|
|
|
* |
6
|
|
|
* (c) Stanislau Komar <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Micro\Plugin\Logger\Monolog; |
13
|
|
|
|
14
|
|
|
use Micro\Framework\Kernel\Configuration\ApplicationConfigurationInterface; |
15
|
|
|
use Micro\Plugin\Logger\LoggerPluginConfiguration; |
16
|
|
|
use Micro\Plugin\Logger\Monolog\Configuration\Logger\LoggerConfiguration; |
17
|
|
|
use Micro\Plugin\Logger\Monolog\Configuration\Logger\LoggerConfigurationInterface; |
18
|
|
|
use Micro\Plugin\Logger\Monolog\Configuration\Logger\MonologPluginConfigurationInterface; |
19
|
|
|
|
20
|
|
|
class MonologPluginConfiguration extends LoggerPluginConfiguration implements MonologPluginConfigurationInterface |
21
|
|
|
{ |
22
|
|
|
public const CFG_HANDLER_LIST = 'LOGGER_HANDLER_LIST'; |
23
|
|
|
|
24
|
|
|
public const CFG_LOGGER_LIST = 'LOGGER_LIST'; |
25
|
|
|
|
26
|
|
|
protected const CFG_HANDLER_TYPE = 'LOGGER_%s_TYPE'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritDoc} |
30
|
|
|
*/ |
31
|
1 |
|
public function getHandlerType(string $handlerName): ?string |
32
|
|
|
{ |
33
|
1 |
|
return $this->configuration->get(sprintf(self::CFG_HANDLER_TYPE, mb_strtoupper($handlerName)), self::HANDLER_DEFAULT_TYPE); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return iterable<string> |
38
|
|
|
*/ |
39
|
1 |
|
public function getLoggerlist(): iterable |
40
|
|
|
{ |
41
|
1 |
|
$loggerListSource = $this->configuration->get(self::CFG_LOGGER_LIST, self::LOGGER_DEFAULT); |
42
|
|
|
|
43
|
1 |
|
return $this->explodeStringToArray($loggerListSource); |
44
|
|
|
} |
45
|
|
|
|
46
|
1 |
|
public function getLoggerConfiguration(string $loggerConfiguration): LoggerConfigurationInterface |
47
|
|
|
{ |
48
|
1 |
|
return new LoggerConfiguration($this->configuration, $loggerConfiguration); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritDoc} |
53
|
|
|
*/ |
54
|
1 |
|
public function getHandlerList(): iterable |
55
|
|
|
{ |
56
|
1 |
|
$handlerListSource = $this->configuration->get(self::CFG_HANDLER_LIST, $this->getHandlerDefault()); |
57
|
|
|
|
58
|
1 |
|
return $this->explodeStringToArray($handlerListSource); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritDoc} |
63
|
|
|
*/ |
64
|
2 |
|
public function getHandlerDefault(): string |
65
|
|
|
{ |
66
|
2 |
|
return self::HANDLER_DEFAULT; |
67
|
|
|
} |
68
|
|
|
|
69
|
1 |
|
public function applicationConfiguration(): ApplicationConfigurationInterface |
70
|
|
|
{ |
71
|
1 |
|
return $this->configuration; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|