Logger::log - allow specifying errno

bump severity of PDO exception log messages to E_USER_WARNING
This commit is contained in:
Andrew Dolgov 2020-09-29 10:08:54 +03:00
parent 3b17c45887
commit 82bc740363
4 changed files with 7 additions and 7 deletions

View File

@ -30,9 +30,9 @@ class Logger {
return false;
}
function log($string, $context = "") {
function log($errno, $errstr, $context = "") {
if ($this->adapter)
return $this->adapter->log_error(E_USER_NOTICE, $string, '', 0, $context);
return $this->adapter->log_error($errno, $errstr, '', 0, $context);
else
return false;
}

View File

@ -20,7 +20,7 @@ class Mailer {
$to_combined = $to_name ? "$to_name <$to_address>" : $to_address;
if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL)
Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message");
Logger::get()->log(E_USER_NOTICE, "Sending mail from $from_combined to $to_combined [$subject]: $message");
// HOOK_SEND_MAIL plugin instructions:
// 1. return 1 or true if mail is handled

View File

@ -176,7 +176,7 @@ class RSSUtils {
Debug::log("!! Last error: $error_message");
Logger::get()->log(
Logger::get()->log(E_USER_NOTICE,
sprintf("Update process for feed %d (%s, owner UID: %d) failed with exit code: %d (%s).",
$tline["id"], clean($tline["title"]), $tline["owner_uid"], $exit_code, clean($error_message)));
}
@ -186,7 +186,7 @@ class RSSUtils {
if (!self::update_rss_feed($tline["id"], true)) {
global $fetch_last_error;
Logger::get()->log(
Logger::get()->log(E_USER_NOTICE,
sprintf("Update request for feed %d (%s, owner UID: %d) failed: %s.",
$tline["id"], clean($tline["title"]), $tline["owner_uid"], clean($fetch_last_error)));
}
@ -194,7 +194,7 @@ class RSSUtils {
Debug::log(sprintf("<= %.4f (sec) (not using a separate process)", microtime(true) - $fstarted));
} catch (PDOException $e) {
Logger::get()->log_error(E_USER_NOTICE, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
Logger::get()->log_error(E_USER_WARNING, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
try {
$pdo->rollback();

View File

@ -268,7 +268,7 @@
Debug::log(sprintf("Exception while updating feed %d: %s (%s:%d)",
$options["update-feed"], $e->getMessage(), $e->getFile(), $e->getLine()));
Logger::get()->log_error(E_USER_NOTICE, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
Logger::get()->log_error(E_USER_WARNING, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
exit(110);
}