-
Notifications
You must be signed in to change notification settings - Fork 0
/
multipleStreams.php
29 lines (23 loc) · 1005 Bytes
/
multipleStreams.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
<?php
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
use Monolog\Processor\MemoryUsageProcessor;
require 'vendor/autoload.php';
// Wrapping in a function to exhibit the IntrospectionProcessor
function traceMe()
{
// So basic
$stdoutHandler = new StreamHandler('php://stdout');
$errorFileHandler = new StreamHandler(__DIR__ . '/multiple.streams.log', Logger::WARNING);
$errorFileHandler->pushProcessor(new MemoryUsageProcessor());
$logger = new Logger('phpdx-experiments-multiple.streams');
$logger->pushHandler($stdoutHandler);
$logger->pushHandler($errorFileHandler);
$logger->pushProcessor(new IntrospectionProcessor());
$logger->debug('look context data', ['foo' => 'bar']);
$logger->info('you will see this in stdout, but not the file');
$logger->warning('warning goes to stdout and the file');
$logger->error('error is handled by both handlers as well', ['serious' => 'error']);
}
traceMe();