Uncommon logger levels in Friendica (#5453)

* "normal" is an uncommon logger level:
- changed LOGGER_NORMAL -> LOGGER_INFO
- added LOGGER_WARNING (a common logger level)

* Used constants instead of values (MrPetovan)
This commit is contained in:
Roland Häder 2018-07-22 20:07:44 +02:00 committed by Hypolite Petovan
parent a202962f03
commit c17adaf333
7 changed files with 29 additions and 25 deletions

View file

@ -113,11 +113,12 @@ define('SSL_POLICY_SELFSIGN', 2);
* log levels * log levels
* @{ * @{
*/ */
define('LOGGER_NORMAL', 0); define('LOGGER_WARNING', 0);
define('LOGGER_TRACE', 1); define('LOGGER_INFO', 1);
define('LOGGER_DEBUG', 2); define('LOGGER_TRACE', 2);
define('LOGGER_DATA', 3); define('LOGGER_DEBUG', 3);
define('LOGGER_ALL', 4); define('LOGGER_DATA', 4);
define('LOGGER_ALL', 5);
/* @}*/ /* @}*/
/** /**

View file

@ -513,7 +513,8 @@ $LOGGER_LEVELS = [];
* @brief Logs the given message at the given log level * @brief Logs the given message at the given log level
* *
* log levels: * log levels:
* LOGGER_NORMAL (default) * LOGGER_WARNING
* LOGGER_INFO (default)
* LOGGER_TRACE * LOGGER_TRACE
* LOGGER_DEBUG * LOGGER_DEBUG
* LOGGER_DATA * LOGGER_DATA
@ -523,7 +524,7 @@ $LOGGER_LEVELS = [];
* @param string $msg * @param string $msg
* @param int $level * @param int $level
*/ */
function logger($msg, $level = 0) { function logger($msg, $level = LOGGER_INFO) {
$a = get_app(); $a = get_app();
global $LOGGER_LEVELS; global $LOGGER_LEVELS;
@ -583,7 +584,8 @@ function logger($msg, $level = 0) {
* personally without background noise * personally without background noise
* *
* log levels: * log levels:
* LOGGER_NORMAL (default) * LOGGER_WARNING
* LOGGER_INFO (default)
* LOGGER_TRACE * LOGGER_TRACE
* LOGGER_DEBUG * LOGGER_DEBUG
* LOGGER_DATA * LOGGER_DATA
@ -593,7 +595,7 @@ function logger($msg, $level = 0) {
* @param string $msg * @param string $msg
* @param int $level * @param int $level
*/ */
function dlogger($msg, $level = 0) { function dlogger($msg, $level = LOGGER_INFO) {
$a = get_app(); $a = get_app();
$logfile = Config::get('system', 'dlogfile'); $logfile = Config::get('system', 'dlogfile');

View file

@ -2356,7 +2356,8 @@ function admin_page_logs_post(App $a)
function admin_page_logs(App $a) function admin_page_logs(App $a)
{ {
$log_choices = [ $log_choices = [
LOGGER_NORMAL => 'Normal', LOGGER_WARNING => 'Warning',
LOGGER_INFO => 'Info',
LOGGER_TRACE => 'Trace', LOGGER_TRACE => 'Trace',
LOGGER_DEBUG => 'Debug', LOGGER_DEBUG => 'Debug',
LOGGER_DATA => 'Data', LOGGER_DATA => 'Data',

View file

@ -142,7 +142,7 @@ class UserImport
// import user // import user
$r = self::dbImportAssoc('user', $account['user']); $r = self::dbImportAssoc('user', $account['user']);
if ($r === false) { if ($r === false) {
logger("uimport:insert user : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL); logger("uimport:insert user : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
notice(L10n::t("User creation error")); notice(L10n::t("User creation error"));
return; return;
} }
@ -160,7 +160,7 @@ class UserImport
$profile['uid'] = $newuid; $profile['uid'] = $newuid;
$r = self::dbImportAssoc('profile', $profile); $r = self::dbImportAssoc('profile', $profile);
if ($r === false) { if ($r === false) {
logger("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL); logger("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
info(L10n::t("User profile creation error")); info(L10n::t("User profile creation error"));
DBA::delete('user', ['uid' => $newuid]); DBA::delete('user', ['uid' => $newuid]);
return; return;
@ -198,7 +198,7 @@ class UserImport
$contact['uid'] = $newuid; $contact['uid'] = $newuid;
$r = self::dbImportAssoc('contact', $contact); $r = self::dbImportAssoc('contact', $contact);
if ($r === false) { if ($r === false) {
logger("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL); logger("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
$errorcount++; $errorcount++;
} else { } else {
$contact['newid'] = self::lastInsertId(); $contact['newid'] = self::lastInsertId();
@ -212,7 +212,7 @@ class UserImport
$group['uid'] = $newuid; $group['uid'] = $newuid;
$r = self::dbImportAssoc('group', $group); $r = self::dbImportAssoc('group', $group);
if ($r === false) { if ($r === false) {
logger("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL); logger("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
} else { } else {
$group['newid'] = self::lastInsertId(); $group['newid'] = self::lastInsertId();
} }
@ -237,7 +237,7 @@ class UserImport
if ($import == 2) { if ($import == 2) {
$r = self::dbImportAssoc('group_member', $group_member); $r = self::dbImportAssoc('group_member', $group_member);
if ($r === false) { if ($r === false) {
logger("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL); logger("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
} }
} }
} }
@ -255,7 +255,7 @@ class UserImport
); );
if ($r === false) { if ($r === false) {
logger("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL); logger("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
} }
} }
@ -263,7 +263,7 @@ class UserImport
$pconfig['uid'] = $newuid; $pconfig['uid'] = $newuid;
$r = self::dbImportAssoc('pconfig', $pconfig); $r = self::dbImportAssoc('pconfig', $pconfig);
if ($r === false) { if ($r === false) {
logger("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL); logger("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
} }
} }

View file

@ -61,7 +61,7 @@ class DBStructure
// No valid result? // No valid result?
if (!DBM::is_result($adminlist)) { if (!DBM::is_result($adminlist)) {
logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL); logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_INFO);
// Don't continue // Don't continue
return; return;

View file

@ -134,7 +134,7 @@ class DFRN
); );
if (! DBM::is_result($r)) { if (! DBM::is_result($r)) {
logger(sprintf('No contact found for nickname=%d', $owner_nick), LOGGER_NORMAL); logger(sprintf('No contact found for nickname=%d', $owner_nick), LOGGER_WARNING);
killme(); killme();
} }
@ -170,7 +170,7 @@ class DFRN
); );
if (! DBM::is_result($r)) { if (! DBM::is_result($r)) {
logger(sprintf('No contact found for uid=%d', $owner_id), LOGGER_NORMAL); logger(sprintf('No contact found for uid=%d', $owner_id), LOGGER_WARNING);
killme(); killme();
} }

View file

@ -220,7 +220,7 @@ class Network
} }
if (curl_errno($ch) !== CURLE_OK) { if (curl_errno($ch) !== CURLE_OK) {
logger('error fetching ' . $url . ': ' . curl_error($ch), LOGGER_NORMAL); logger('error fetching ' . $url . ': ' . curl_error($ch), LOGGER_INFO);
} }
$ret['errno'] = curl_errno($ch); $ret['errno'] = curl_errno($ch);