Reduce volume of logs and improve log reliability.

This commit is contained in:
Buster "Silver Eagle" Neece 2022-06-11 07:21:03 -05:00
parent 344220daab
commit a3b0ee5ce6
No known key found for this signature in database
GPG key ID: F1D2E64A0005E80E
3 changed files with 17 additions and 10 deletions

View file

@ -286,7 +286,7 @@ return [
$logger = new Monolog\Logger($environment->getAppName());
$loggingLevel = $environment->getLogLevel();
if ($environment->isDocker() || $environment->isCli()) {
if ($environment->isCli() || $environment->isDocker()) {
$log_stderr = new Monolog\Handler\StreamHandler('php://stderr', $loggingLevel, true);
$logger->pushHandler($log_stderr);
}
@ -365,15 +365,18 @@ return [
Symfony\Component\Messenger\MessageBus::class => static function (
App\MessageQueue\QueueManager $queueManager,
\App\Lock\LockFactory $lockFactory,
App\Lock\LockFactory $lockFactory,
Monolog\Logger $logger,
ContainerInterface $di,
App\Plugins $plugins,
Environment $environment
) {
$loggingLevel = $environment->getLogLevel();
$busLogger = new Psr\Log\NullLogger();
// Configure message sending middleware
$sendMessageMiddleware = new Symfony\Component\Messenger\Middleware\SendMessageMiddleware($queueManager);
$sendMessageMiddleware->setLogger($logger);
$sendMessageMiddleware->setLogger($busLogger);
// Configure message handling middleware
$handlers = [];
@ -395,7 +398,7 @@ return [
$handlersLocator,
true
);
$handleMessageMiddleware->setLogger($logger);
$handleMessageMiddleware->setLogger($busLogger);
// Add unique protection middleware
$uniqueMiddleware = new App\MessageQueue\HandleUniqueMiddleware($lockFactory);

View file

@ -12,6 +12,8 @@ use App\MessageQueue\QueueManagerInterface;
use App\MessageQueue\ResetArrayCacheMiddleware;
use Azura\SlimCallableEventDispatcher\CallableEventDispatcherInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Psr\Log\NullLogger;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@ -74,17 +76,21 @@ class ProcessCommand extends CommandAbstract
: 30;
}
$this->eventDispatcher->addSubscriber(new StopWorkerOnTimeLimitListener($runtime, $this->logger));
$busLogger = (LogLevel::DEBUG === $this->environment->getLogLevel())
? $this->logger
: new NullLogger();
$this->eventDispatcher->addSubscriber(new StopWorkerOnTimeLimitListener($runtime, $busLogger));
try {
$worker = new Worker($receivers, $this->messageBus, $this->eventDispatcher, $this->logger);
$worker = new Worker($receivers, $this->messageBus, $this->eventDispatcher, $busLogger);
$worker->run();
} catch (Throwable $e) {
$this->logger->error(
sprintf('Message queue error: %s', $e->getMessage()),
[
'workerName' => $workerName,
'exception' => $e,
'exception' => $e,
]
);
return 1;

View file

@ -1,6 +1,5 @@
[global]
error_log = syslog
error_log = /dev/stderr
daemonize = no
[www]
@ -22,7 +21,6 @@ pm.status_path = /status
pm.process_idle_timeout = 60s
chdir = /
clear_env=No
catch_workers_output = yes
decorate_workers_output = no