<?php
use Monolog\{Handler,Processor,Formatter,Level};

function buildLogger() {
    $logger = new Monolog\Logger('global', [
        new Handler\FilterHandler(new Handler\RotatingFileHandler('/logs/php.log'),
            Level::Debug,
            Level::Notice
        ),
        new Handler\FilterHandler(new Handler\RotatingFileHandler('/logs/error.log'),
            Level::Warning,
            Level::Critical
        ),
        new Handler\FilterHandler(new Handler\NativeMailerHandler('jpvial@incoviba.cl', 'Incoviba Error', 'alert@incoviba.cl'),
            Level::Alert
        )
    ], [
        new Processor\PsrLogMessageProcessor(),
        new Processor\IntrospectionProcessor(),
        new Processor\WebProcessor(),
        new Processor\MemoryPeakUsageProcessor()
    ]);
    return $logger;
}
$logger = buildLogger();
Monolog\ErrorHandler::register($logger);
