Merge pull request #11530 from annando/logruntime

Configuration for logging added
This commit is contained in:
Tobias Diekershoff 2022-05-18 08:17:50 +02:00 committed by GitHub
commit 7d958e8804
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 4 deletions

View file

@ -719,7 +719,7 @@ class App
} catch (HTTPException $e) { } catch (HTTPException $e) {
(new ModuleHTTPException())->rawContent($e); (new ModuleHTTPException())->rawContent($e);
} }
$page->logRuntime(); $page->logRuntime($this->config);
} }
/** /**

View file

@ -98,10 +98,16 @@ class Page implements ArrayAccess
$this->method = $method; $this->method = $method;
} }
public function logRuntime() public function logRuntime(IManageConfigValues $config)
{ {
if (in_array($this->command, $config->get('system', 'runtime_ignore'))) {
return;
}
$runtime = number_format(microtime(true) - $this->timestamp, 3); $runtime = number_format(microtime(true) - $this->timestamp, 3);
Logger::debug('Runtime', ['method' => $this->method, 'command' => $this->command, 'runtime' => $runtime]); if ($runtime > $config->get('system', 'runtime_loglimit')) {
Logger::debug('Runtime', ['method' => $this->method, 'command' => $this->command, 'runtime' => $runtime]);
}
} }
/** /**

View file

@ -369,7 +369,7 @@ class System
*/ */
public static function exit() public static function exit()
{ {
DI::page()->logRuntime(); DI::page()->logRuntime(DI::config());
exit(); exit();
} }

View file

@ -507,6 +507,14 @@ return [
// If enabled, multiple linefeeds in items are stripped to a single one. // If enabled, multiple linefeeds in items are stripped to a single one.
'remove_multiplicated_lines' => false, 'remove_multiplicated_lines' => false,
// runtime_ignore (Array)
// List of ignored commands for the runtime logging.
'runtime_ignore' => [],
// runtime_loglimit (Integer)
// The runtime is logged, When the program execution time is higher than this value.
'runtime_loglimit' => 0,
// sendmail_params (Boolean) // sendmail_params (Boolean)
// Normal sendmail command parameters will be added when the PHP mail() function is called for sending e-mails. // Normal sendmail command parameters will be added when the PHP mail() function is called for sending e-mails.
// This ensures the Sender Email address setting is applied to the message envelope rather than the host's default address. // This ensures the Sender Email address setting is applied to the message envelope rather than the host's default address.