Log function

implement log() function.
This commit is contained in:
Adam Magness 2018-10-29 17:20:46 -04:00
parent d6d593d724
commit 14fde5dc9b
122 changed files with 1280 additions and 1161 deletions

View file

@ -5,6 +5,7 @@
namespace Friendica\Core;
use Friendica\App;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\Photo;
@ -37,7 +38,7 @@ class UserImport
private static function checkCols($table, &$arr)
{
$query = sprintf("SHOW COLUMNS IN `%s`", DBA::escape($table));
logger("uimport: $query", LOGGER_DEBUG);
Logger::log("uimport: $query", LOGGER_DEBUG);
$r = q($query);
$tcols = [];
// get a plain array of column names
@ -68,7 +69,7 @@ class UserImport
$cols = implode("`,`", array_map(['Friendica\Database\DBA', 'escape'], array_keys($arr)));
$vals = implode("','", array_map(['Friendica\Database\DBA', 'escape'], array_values($arr)));
$query = "INSERT INTO `$table` (`$cols`) VALUES ('$vals')";
logger("uimport: $query", LOGGER_TRACE);
Logger::log("uimport: $query", LOGGER_TRACE);
if (self::IMPORT_DEBUG) {
return true;
@ -85,7 +86,7 @@ class UserImport
*/
public static function importAccount(App $a, $file)
{
logger("Start user import from " . $file['tmp_name']);
Logger::log("Start user import from " . $file['tmp_name']);
/*
STEPS
1. checks
@ -143,7 +144,7 @@ class UserImport
// import user
$r = self::dbImportAssoc('user', $account['user']);
if ($r === false) {
logger("uimport:insert user : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
Logger::log("uimport:insert user : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
notice(L10n::t("User creation error"));
return;
}
@ -161,7 +162,7 @@ class UserImport
$profile['uid'] = $newuid;
$r = self::dbImportAssoc('profile', $profile);
if ($r === false) {
logger("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
Logger::log("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
info(L10n::t("User profile creation error"));
DBA::delete('user', ['uid' => $newuid]);
return;
@ -199,7 +200,7 @@ class UserImport
$contact['uid'] = $newuid;
$r = self::dbImportAssoc('contact', $contact);
if ($r === false) {
logger("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
Logger::log("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
$errorcount++;
} else {
$contact['newid'] = self::lastInsertId();
@ -213,7 +214,7 @@ class UserImport
$group['uid'] = $newuid;
$r = self::dbImportAssoc('group', $group);
if ($r === false) {
logger("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
Logger::log("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
} else {
$group['newid'] = self::lastInsertId();
}
@ -238,7 +239,7 @@ class UserImport
if ($import == 2) {
$r = self::dbImportAssoc('group_member', $group_member);
if ($r === false) {
logger("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
Logger::log("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
}
}
}
@ -256,7 +257,7 @@ class UserImport
);
if ($r === false) {
logger("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
Logger::log("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
}
}
@ -264,7 +265,7 @@ class UserImport
$pconfig['uid'] = $newuid;
$r = self::dbImportAssoc('pconfig', $pconfig);
if ($r === false) {
logger("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
Logger::log("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO);
}
}