feature/cierres (#25)
Varios cambios Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl> Reviewed-on: #25
This commit is contained in:
@ -1,65 +1,154 @@
|
||||
<?php
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
return [
|
||||
Monolog\Processor\WebProcessor::class => function(ContainerInterface $container) {
|
||||
return new Monolog\Processor\WebProcessor(null, [
|
||||
'HTTP_X_FORWARDED_FOR',
|
||||
'HTTP_CLIENT_IP',
|
||||
'HTTP_X_CLIENT_IP',
|
||||
'HTTP_X_REAL_IP',
|
||||
'REMOTE_ADDR',
|
||||
'REMOTE_HOST',
|
||||
]);
|
||||
},
|
||||
Monolog\Formatter\LineFormatter::class => function(ContainerInterface $container) {
|
||||
return (new Monolog\Formatter\LineFormatter(null, null, false, false, true))
|
||||
->setBasePath('/code/');
|
||||
},
|
||||
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
||||
return new Monolog\Logger('incoviba', [
|
||||
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::Error,
|
||||
Monolog\Level::Error
|
||||
),
|
||||
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
|
||||
),
|
||||
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\RedisHandler($container->get(Predis\ClientInterface::class), 'logs:notices'),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Info
|
||||
),
|
||||
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 Incoviba\Common\Implement\Log\MySQLHandler($container->get(Incoviba\Common\Define\Connection::class)))
|
||||
->setFormatter(new Incoviba\Common\Implement\Log\PDOFormatter()),
|
||||
Monolog\Level::Notice,
|
||||
Monolog\Level::Warning
|
||||
)
|
||||
], [
|
||||
$container->get(Incoviba\Common\Implement\Log\UserProcessor::class),
|
||||
'baseMonologProcessors' => function(ContainerInterface $container) {
|
||||
return [
|
||||
$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),
|
||||
]);
|
||||
$container->get(Monolog\Processor\UidProcessor::class),
|
||||
];
|
||||
},
|
||||
'baseDefaultHandlers' => function(ContainerInterface $container) {
|
||||
return [
|
||||
'critical' => [
|
||||
'handler' => Monolog\Handler\RotatingFileHandler::class,
|
||||
'filename' => 'critical.log',
|
||||
'levels' => Monolog\Level::Critical
|
||||
],
|
||||
'error' => [
|
||||
'handler' => Monolog\Handler\RotatingFileHandler::class,
|
||||
'filename' => 'error.log',
|
||||
'levels' => [Monolog\Level::Error, Monolog\Level::Error],
|
||||
],
|
||||
'notices' => [
|
||||
'handler' => Incoviba\Common\Implement\Log\Handler\MySQL::class,
|
||||
'levels' => [Monolog\Level::Notice, Monolog\Level::Warning]
|
||||
],
|
||||
'debug' => [
|
||||
'handler' => Monolog\Handler\RedisHandler::class,
|
||||
'name' => 'notices',
|
||||
'levels' => [Monolog\Level::Debug, Monolog\Level::Info]
|
||||
],
|
||||
];
|
||||
},
|
||||
'developmentHandlers' => function(ContainerInterface $container) {
|
||||
$baseHandlers = $container->get('baseDefaultHandlers');
|
||||
$baseHandlers['critical']['handler'] = Monolog\Handler\StreamHandler::class;
|
||||
$baseHandlers['error']['handler'] = Monolog\Handler\StreamHandler::class;
|
||||
$baseHandlers['notices']['handler'] = Monolog\Handler\StreamHandler::class;
|
||||
$baseHandlers['notices']['filename'] = 'notices.log';
|
||||
$baseHandlers['debug']['handler'] = Monolog\Handler\StreamHandler::class;
|
||||
$baseHandlers['debug']['filename'] = 'debug.log';
|
||||
return $baseHandlers;
|
||||
},
|
||||
'defaultMonologHandlers' => function(ContainerInterface $container) {
|
||||
$key = 'baseDefault';
|
||||
if ($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development') {
|
||||
$key = 'development';
|
||||
if (!$container->has("{$key}Handlers")) {
|
||||
$key = 'baseDefault';
|
||||
}
|
||||
}
|
||||
$baseHandlers = $container->get("{$key}Handlers");
|
||||
$builder = $container->get(Incoviba\Common\Implement\Log\Processor\ArrayBuilder::class);
|
||||
return $builder->build($baseHandlers);
|
||||
},
|
||||
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
||||
return new Monolog\Logger('incoviba',
|
||||
$container->get('defaultMonologHandlers'),
|
||||
[$container->get(Incoviba\Common\Implement\Log\Processor\User::class)]
|
||||
+ $container->get('baseMonologProcessors'),
|
||||
$container->get(DateTimeZone::class)
|
||||
);
|
||||
},
|
||||
'jsonHandlers' => function(ContainerInterface $container) {
|
||||
$baseHandlers = $container->get('baseDefaultHandlers');
|
||||
$baseHandlers['debug']['handler'] = Monolog\Handler\RotatingFileHandler::class;
|
||||
$baseHandlers['debug']['filename'] = 'info.json';
|
||||
$baseHandlers['debug']['formatter'] = Monolog\Formatter\JsonFormatter::class;
|
||||
$baseHandlers['notices']['handler'] = Monolog\Handler\RotatingFileHandler::class;
|
||||
$baseHandlers['notices']['filename'] = 'notices.json';
|
||||
$baseHandlers['notices']['formatter'] = Monolog\Formatter\JsonFormatter::class;
|
||||
return $baseHandlers;
|
||||
},
|
||||
'jsonLogger' => function(ContainerInterface $container) {
|
||||
$builder = $container->get(Incoviba\Common\Implement\Log\Processor\ArrayBuilder::class);
|
||||
$handlers = $builder->build($container->get('jsonHandlers'));
|
||||
return new Monolog\Logger('json',
|
||||
$handlers,
|
||||
[$container->get(Incoviba\Common\Implement\Log\Processor\User::class)]
|
||||
+ $container->get('baseMonologProcessors'),
|
||||
$container->get(DateTimeZone::class)
|
||||
);
|
||||
},
|
||||
'loginLogger' => function(ContainerInterface $container) {
|
||||
return new Monolog\Logger('login', [
|
||||
new Monolog\Handler\RedisHandler($container->get(Predis\ClientInterface::class), 'logs:login'),
|
||||
], [
|
||||
$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),
|
||||
]);
|
||||
}
|
||||
return new Monolog\Logger('login',
|
||||
[
|
||||
new Monolog\Handler\RedisHandler($container->get(Predis\ClientInterface::class), 'logs:login'),
|
||||
],
|
||||
$container->get('baseMonologProcessors'),
|
||||
$container->get(DateTimeZone::class)
|
||||
);
|
||||
},
|
||||
'accessLogger' => function(ContainerInterface $container) {
|
||||
return new Monolog\Logger('access',
|
||||
[
|
||||
new Monolog\Handler\RedisHandler($container->get(Predis\ClientInterface::class), 'logs:access'),
|
||||
],
|
||||
$container->get('baseMonologProcessors'),
|
||||
$container->get(DateTimeZone::class)
|
||||
);
|
||||
},
|
||||
'externalHandlers' => function(ContainerInterface $container) {
|
||||
return [
|
||||
'critical' => [
|
||||
'handler' => Monolog\Handler\RedisHandler::class,
|
||||
'name' => 'external:critical',
|
||||
'levels' => Monolog\Level::Critical
|
||||
],
|
||||
'error' => [
|
||||
'handler' => Monolog\Handler\RedisHandler::class,
|
||||
'name' => 'external:error',
|
||||
'levels' => [Monolog\Level::Error, Monolog\Level::Error],
|
||||
],
|
||||
'notices' => [
|
||||
'handler' => Monolog\Handler\RedisHandler::class,
|
||||
'name' => 'external:notices',
|
||||
'levels' => [Monolog\Level::Notice, Monolog\Level::Warning],
|
||||
],
|
||||
'debug' => [
|
||||
'handler' => Monolog\Handler\RedisHandler::class,
|
||||
'name' => 'external:debug',
|
||||
'levels' => [Monolog\Level::Debug, Monolog\Level::Info],
|
||||
],
|
||||
];
|
||||
},
|
||||
'externalLogger' => function(ContainerInterface $container) {
|
||||
$builder = $container->get(Incoviba\Common\Implement\Log\Processor\ArrayBuilder::class);
|
||||
$handlers = $builder->build($container->get('externalHandlers'));
|
||||
return new Monolog\Logger('external',
|
||||
$handlers,
|
||||
$container->get('baseMonologProcessors'),
|
||||
$container->get(DateTimeZone::class)
|
||||
);
|
||||
},
|
||||
];
|
||||
|
Reference in New Issue
Block a user