<?php
use Psr\Container\ContainerInterface;

return [
    Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
        return new Monolog\Logger('incoviba', [
            new Monolog\Handler\FilterHandler(
                (new Monolog\Handler\RotatingFileHandler('/logs/error.log', 10))
                    ->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
                Monolog\Level::Error,
                Monolog\Level::Error
            ),
            new Monolog\Handler\FilterHandler(
                (new Monolog\Handler\RotatingFileHandler('/logs/critical.log', 10))
                    ->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
                Monolog\Level::Critical
            ),
            new Monolog\Handler\FilterHandler(
                new Monolog\Handler\RedisHandler($container->get(Predis\ClientInterface::class), 'logs:notices'),
                Monolog\Level::Notice,
                Monolog\Level::Warning
            ),
            new Monolog\Handler\FilterHandler(
                (new Incoviba\Common\Implement\Log\MySQLHandler($container->get(Incoviba\Common\Define\Connection::class)))
                    ->setFormatter(new Incoviba\Common\Implement\Log\PDOFormatter()),
                Monolog\Level::Debug,
                Monolog\Level::Warning
            )
        ], [
            $container->get(Incoviba\Common\Implement\Log\UserProcessor::class),
            $container->get(Monolog\Processor\IntrospectionProcessor::class),
            $container->get(Monolog\Processor\WebProcessor::class),
            $container->get(Monolog\Processor\MemoryUsageProcessor::class),
            $container->get(Monolog\Processor\MemoryPeakUsageProcessor::class),
            $container->get(Monolog\Processor\PsrLogMessageProcessor::class),
        ]);
    }
];
