feature/cierres (#25)
Varios cambios Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl> Reviewed-on: #25
This commit is contained in:
@ -3,35 +3,124 @@ 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/debug.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Debug
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
(new Monolog\Handler\RotatingFileHandler('/logs/info.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Info,
|
||||
Monolog\Level::Warning,
|
||||
),
|
||||
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
|
||||
)
|
||||
], [
|
||||
$minLogLevel = Monolog\Level::Debug;
|
||||
if ($container->has('DEBUG') and $container->get('DEBUG') === 'false') {
|
||||
$minLogLevel = Monolog\Level::Warning;
|
||||
}
|
||||
$handlers = [];
|
||||
switch($minLogLevel) {
|
||||
case Monolog\Level::Debug:
|
||||
$handlers []= new Monolog\Handler\FilterHandler(
|
||||
($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development')
|
||||
? (new Monolog\Handler\StreamHandler('/logs/debug.log'))
|
||||
->setFormatter($container->get(Monolog\Formatter\LineFormatter::class))
|
||||
: (new Monolog\Handler\RotatingFileHandler('/logs/debug.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Debug,
|
||||
false
|
||||
);
|
||||
case Monolog\Level::Info:
|
||||
case Monolog\Level::Notice:
|
||||
$handlers []= new Monolog\Handler\FilterHandler(
|
||||
($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development')
|
||||
? (new Monolog\Handler\StreamHandler('/logs/notices.log'))
|
||||
->setFormatter($container->get(Monolog\Formatter\LineFormatter::class))
|
||||
: (new Monolog\Handler\RotatingFileHandler('/logs/info.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Info,
|
||||
Monolog\Level::Notice,
|
||||
false
|
||||
);
|
||||
case Monolog\Level::Warning:
|
||||
case Monolog\Level::Error:
|
||||
$handlers []= new Monolog\Handler\FilterHandler(
|
||||
($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development')
|
||||
? (new Monolog\Handler\StreamHandler('/logs/error.log'))
|
||||
->setFormatter($container->get(Monolog\Formatter\LineFormatter::class))
|
||||
: (new Monolog\Handler\RotatingFileHandler('/logs/error.log', 10))
|
||||
->setFormatter($container->get(Monolog\Formatter\LineFormatter::class)),
|
||||
Monolog\Level::Warning,
|
||||
Monolog\Level::Error,
|
||||
false
|
||||
);
|
||||
case Monolog\Level::Critical:
|
||||
case Monolog\Level::Alert:
|
||||
case Monolog\Level::Emergency:
|
||||
$handlers []= new Monolog\Handler\FilterHandler(
|
||||
($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development')
|
||||
? (new Monolog\Handler\StreamHandler('/logs/critical.log'))
|
||||
->setFormatter($container->get(Monolog\Formatter\LineFormatter::class))
|
||||
: (new Monolog\Handler\RotatingFileHandler('/logs/critical.log', 10))
|
||||
->setFormatter($container->get(Monolog\Formatter\LineFormatter::class)),
|
||||
Monolog\Level::Critical
|
||||
);
|
||||
}
|
||||
return new Monolog\Logger('incoviba', $handlers, [
|
||||
$container->get(Monolog\Processor\PsrLogMessageProcessor::class),
|
||||
$container->get(Monolog\Processor\IntrospectionProcessor::class),
|
||||
$container->get(Monolog\Processor\MemoryUsageProcessor::class),
|
||||
$container->get(Monolog\Processor\MemoryPeakUsageProcessor::class)
|
||||
]);
|
||||
], $container->get(DateTimeZone::class));
|
||||
},
|
||||
'LoopLogger' => function(ContainerInterface $container) {
|
||||
$handlers = [
|
||||
'warning' => new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\RotatingFileHandler('/logs/loop-error.log', 10),
|
||||
Monolog\Level::Warning
|
||||
),
|
||||
'notice' => new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\RotatingFileHandler('/logs/loop.log', 10),
|
||||
Monolog\Level::Notice,
|
||||
Monolog\Level::Notice
|
||||
),
|
||||
'debug' => new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\RotatingFileHandler('/logs/loop-debug.log', 10),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Debug
|
||||
)
|
||||
];
|
||||
if ($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development') {
|
||||
$handlers['warning'] = new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\StreamHandler('/logs/loop-error.log'),
|
||||
Monolog\Level::Warning);
|
||||
$handlers['notice'] = new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\StreamHandler('/logs/loop.log'),
|
||||
Monolog\Level::Notice, Monolog\Level::Notice);
|
||||
$handlers['debug'] = new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\StreamHandler('/logs/loop-debug.log'),
|
||||
Monolog\Level::Debug, Monolog\Level::Debug);
|
||||
}
|
||||
return new Monolog\Logger('loop', $handlers, [], $container->get(DateTimeZone::class));
|
||||
},
|
||||
'QueueLogger' => function(ContainerInterface $container) {
|
||||
$handlers = [
|
||||
'warning' => new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\RotatingFileHandler('/logs/queue-error.log', 10),
|
||||
Monolog\Level::Warning
|
||||
),
|
||||
'notice' => new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\RotatingFileHandler('/logs/queue.log', 10),
|
||||
Monolog\Level::Notice,
|
||||
Monolog\Level::Notice
|
||||
),
|
||||
'debug' => new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\RotatingFileHandler('/logs/queue-debug.log', 10),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Debug
|
||||
)
|
||||
];
|
||||
if ($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development') {
|
||||
$handlers['warning'] = new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\StreamHandler('/logs/queue-error.log'),
|
||||
Monolog\Level::Warning);
|
||||
$handlers['notice'] = new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\StreamHandler('/logs/queue.log'),
|
||||
Monolog\Level::Notice, Monolog\Level::Notice);
|
||||
$handlers['debug'] = new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\StreamHandler('/logs/queue-debug.log'),
|
||||
Monolog\Level::Debug, Monolog\Level::Debug);
|
||||
}
|
||||
return new Monolog\Logger('queue', $handlers, [], $container->get(DateTimeZone::class));
|
||||
}
|
||||
];
|
||||
|
Reference in New Issue
Block a user