BaseLoop different logger
This commit is contained in:
8
cli/setup/settings/other.php
Normal file
8
cli/setup/settings/other.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
return [
|
||||
DateTimeZone::class => function (ContainerInterface $container) {
|
||||
return new DateTimeZone($container->get('TZ') ?? 'America/Santiago');
|
||||
},
|
||||
];
|
@ -11,5 +11,11 @@ return [
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get('commands')
|
||||
);
|
||||
},
|
||||
Incoviba\Command\BaseLoop::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Command\BaseLoop(
|
||||
$container->get('LoopLogger'),
|
||||
$container->get(Incoviba\Service\Schedule::class)
|
||||
);
|
||||
}
|
||||
];
|
||||
|
@ -61,6 +61,23 @@ return [
|
||||
$container->get(Monolog\Processor\IntrospectionProcessor::class),
|
||||
$container->get(Monolog\Processor\MemoryUsageProcessor::class),
|
||||
$container->get(Monolog\Processor\MemoryPeakUsageProcessor::class)
|
||||
], new DateTimeZone($container->get('TZ')));
|
||||
], $container->get(DateTimeZone::class));
|
||||
},
|
||||
'LoopLogger' => function(ContainerInterface $container) {
|
||||
return new Monolog\Logger('loop', [
|
||||
new Monolog\Handler\FilterHandler(
|
||||
($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development')
|
||||
? new Monolog\Handler\StreamHandler('/logs/loop.log')
|
||||
: new Monolog\Handler\RotatingFileHandler('/logs/loop.log', 10),
|
||||
Monolog\Level::Notice
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development')
|
||||
? new Monolog\Handler\StreamHandler('/logs/loop-debug.log')
|
||||
: new Monolog\Handler\RotatingFileHandler('/logs/loop-debug.log', 10),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Debug
|
||||
)
|
||||
], [], $container->get(DateTimeZone::class));
|
||||
}
|
||||
];
|
||||
|
@ -44,10 +44,6 @@ class BaseLoop extends Console\Command\Command
|
||||
}
|
||||
$nextMinute = new DateTimeImmutable($start->format('Y-m-d H:i:00'));
|
||||
$nextMinute = $nextMinute->add(new \DateInterval('PT1M'));
|
||||
$this->logger->debug('Wait', [
|
||||
'start' => $start->format('Y-m-d H:i:s.u'),
|
||||
'nextMinute' => $nextMinute->format('Y-m-d H:i:s.u'),
|
||||
]);
|
||||
$diff = $nextMinute->getTimestamp() - $start->getTimestamp();
|
||||
if ($diff > 0) {
|
||||
$this->logger->debug("Waiting {$diff} seconds...");
|
||||
@ -66,6 +62,7 @@ class BaseLoop extends Console\Command\Command
|
||||
'command' => $commandName
|
||||
]);
|
||||
try {
|
||||
$this->logger->notice("Running commnand: {$commandName}");
|
||||
return $this->getApplication()->doRun($cmd, $output);
|
||||
} catch (Throwable $exception) {
|
||||
$this->logger->warning($exception);
|
||||
|
Reference in New Issue
Block a user