From d1ea529cfbfe3b42d7dc34efe55a3cc9cf84d97f Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 31 Dec 2020 20:14:13 +0000 Subject: [PATCH 1/2] Issue 9704: Improved log levels --- src/Core/Worker.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Core/Worker.php b/src/Core/Worker.php index fb3470270..2f39a82fe 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -103,7 +103,7 @@ class Worker // The work will be done if (!self::execute($entry)) { - Logger::info('Process execution failed, quitting.'); + Logger::notice('Process execution failed, quitting.'); return; } @@ -125,14 +125,14 @@ class Worker if (DI::lock()->acquire(self::LOCK_WORKER, 0)) { // Count active workers and compare them with a maximum value that depends on the load if (self::tooMuchWorkers()) { - Logger::info('Active worker limit reached, quitting.'); + Logger::notice('Active worker limit reached, quitting.'); DI::lock()->release(self::LOCK_WORKER); return; } // Check free memory if (DI::process()->isMinMemoryReached()) { - Logger::notice('Memory limit reached, quitting.'); + Logger::warning('Memory limit reached, quitting.'); DI::lock()->release(self::LOCK_WORKER); return; } @@ -168,25 +168,25 @@ class Worker { // Count active workers and compare them with a maximum value that depends on the load if (self::tooMuchWorkers()) { - Logger::info('Active worker limit reached, quitting.'); + Logger::notice('Active worker limit reached, quitting.'); return false; } // Do we have too few memory? if (DI::process()->isMinMemoryReached()) { - Logger::notice('Memory limit reached, quitting.'); + Logger::warning('Memory limit reached, quitting.'); return false; } // Possibly there are too much database connections if (self::maxConnectionsReached()) { - Logger::notice('Maximum connections reached, quitting.'); + Logger::warning('Maximum connections reached, quitting.'); return false; } // Possibly there are too much database processes that block the system if (DI::process()->isMaxProcessesReached()) { - Logger::notice('Maximum processes reached, quitting.'); + Logger::warning('Maximum processes reached, quitting.'); return false; } @@ -290,13 +290,13 @@ class Worker // Constantly check the number of parallel database processes if (DI::process()->isMaxProcessesReached()) { - Logger::notice("Max processes reached for process", ['pid' => $mypid]); + Logger::warning("Max processes reached for process", ['pid' => $mypid]); return false; } // Constantly check the number of available database connections to let the frontend be accessible at any time if (self::maxConnectionsReached()) { - Logger::notice("Max connection reached for process", ['pid' => $mypid]); + Logger::warning("Max connection reached for process", ['pid' => $mypid]); return false; } @@ -540,7 +540,7 @@ class Worker $level = ($used / $max) * 100; if ($level >= $maxlevel) { - Logger::notice("Maximum level (".$maxlevel."%) of user connections reached: ".$used."/".$max); + Logger::warning("Maximum level (".$maxlevel."%) of user connections reached: ".$used."/".$max); return true; } } @@ -570,7 +570,7 @@ class Worker if ($level < $maxlevel) { return false; } - Logger::notice("Maximum level (".$level."%) of system connections reached: ".$used."/".$max); + Logger::warning("Maximum level (".$level."%) of system connections reached: ".$used."/".$max); return true; } @@ -1352,7 +1352,7 @@ class Worker $new_retrial = $retrial; } } - Logger::info('New retrial for task', ['id' => $queue['id'], 'created' => $queue['created'], 'old' => $queue['retrial'], 'new' => $new_retrial]); + Logger::notice('New retrial for task', ['id' => $queue['id'], 'created' => $queue['created'], 'old' => $queue['retrial'], 'new' => $new_retrial]); return $new_retrial; } @@ -1378,7 +1378,7 @@ class Worker $new_retrial = self::getNextRetrial($queue, $max_level); if ($new_retrial > $max_level) { - Logger::info('The task exceeded the maximum retry count', ['id' => $id, 'created' => $queue['created'], 'old_prio' => $queue['priority'], 'old_retrial' => $queue['retrial'], 'max_level' => $max_level, 'retrial' => $new_retrial]); + Logger::notice('The task exceeded the maximum retry count', ['id' => $id, 'created' => $queue['created'], 'old_prio' => $queue['priority'], 'old_retrial' => $queue['retrial'], 'max_level' => $max_level, 'retrial' => $new_retrial]); return false; } @@ -1490,12 +1490,12 @@ class Worker */ private static function spawnDaemon() { - Logger::info('Starting new daemon process'); + Logger::notice('Starting new daemon process'); $command = 'bin/daemon.php'; $a = DI::app(); $process = new Core\Process(DI::logger(), DI::mode(), DI::config(), DI::modelProcess(), $a->getBasePath(), getmypid()); $process->run($command, ['start']); - Logger::info('New daemon process started'); + Logger::notice('New daemon process started'); } /** From 5dcc02594c586bcccfa8f4e3e034973114908012 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 31 Dec 2020 20:44:33 +0000 Subject: [PATCH 2/2] Some more log levels --- src/Core/Process.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Core/Process.php b/src/Core/Process.php index 06653cbe3..919d37dea 100644 --- a/src/Core/Process.php +++ b/src/Core/Process.php @@ -179,7 +179,7 @@ class Process $reached = ($free < $min_memory); if ($reached) { - $this->logger->debug('Minimal memory reached.', ['free' => $free, 'memtotal' => $meminfo['MemTotal'], 'limit' => $min_memory]); + $this->logger->warning('Minimal memory reached.', ['free' => $free, 'memtotal' => $meminfo['MemTotal'], 'limit' => $min_memory]); } return $reached; @@ -209,7 +209,7 @@ class Process $load = System::currentLoad(); if ($load) { if (intval($load) > $maxsysload) { - $this->logger->info('system load for process too high.', ['load' => $load, 'process' => $process, 'maxsysload' => $maxsysload]); + $this->logger->warning('system load for process too high.', ['load' => $load, 'process' => $process, 'maxsysload' => $maxsysload]); return true; } } @@ -225,7 +225,7 @@ class Process public function run($command, $args) { if (!function_exists('proc_open')) { - $this->logger->notice('"proc_open" not available - quitting'); + $this->logger->warning('"proc_open" not available - quitting'); return; } @@ -243,7 +243,7 @@ class Process } if ($this->isMinMemoryReached()) { - $this->logger->notice('Memory limit reached - quitting'); + $this->logger->warning('Memory limit reached - quitting'); return; } @@ -253,7 +253,7 @@ class Process $resource = proc_open($cmdline . ' &', [], $foo, $this->basePath); } if (!is_resource($resource)) { - $this->logger->notice('We got no resource for command.', ['command' => $cmdline]); + $this->logger->warning('We got no resource for command.', ['command' => $cmdline]); return; } proc_close($resource);