-
Notifications
You must be signed in to change notification settings - Fork 4
/
generic-factory.php
47 lines (41 loc) · 1.12 KB
/
generic-factory.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
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
require_once __DIR__ . '/../vendor/autoload.php';
use Monolog\Formatter\HtmlFormatter;
use Monolog\Handler\NativeMailerHandler;
use Monolog\Handler\NullHandler;
use Monolog\Logger;
use Monolog\Processor\PsrLogMessageProcessor;
use MonologFactory\LoggerFactory;
$loggerFactory = new LoggerFactory();
//manual handler/processor creation
$logger1 = $loggerFactory->create('logger1', [
'handlers' => [
new NullHandler(),
],
'processors' => [
new PsrLogMessageProcessor(),
],
]);
//plain-array handlers/processors configuration
$logger2 = $loggerFactory->create('logger2', [
'handlers' => [
[
'name' => NativeMailerHandler::class,
'params' => [
'to' => '[email protected]',
'subject' => 'Test',
'from' => '[email protected]',
'level' => Logger::ALERT,
],
'formatter' => [
'name' => HtmlFormatter::class,
],
],
],
'processors' => [
[
'name' => PsrLogMessageProcessor::class,
],
],
]);