LoggerServiceProvider.php
1.0 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
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Service;
use Yansongda\Pay\Contract\ConfigInterface;
use Yansongda\Pay\Contract\LoggerInterface;
use Yansongda\Pay\Contract\ServiceProviderInterface;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Supports\Logger;
class LoggerServiceProvider implements ServiceProviderInterface
{
/**
* @param mixed $data
*
* @throws ContainerException
* @throws ServiceNotFoundException
*/
public function register($data = null): void
{
/* @var ConfigInterface $config */
$config = Pay::get(ConfigInterface::class);
if (class_exists(\Monolog\Logger::class) && true === $config->get('logger.enable', false)) {
$logger = new Logger(array_merge(
['identify' => 'yansongda.pay'],
$config->get('logger', [])
));
Pay::set(LoggerInterface::class, $logger);
}
}
}