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

@ -36,7 +36,7 @@ class Inbox extends BaseModule
$tempfile = tempnam(get_temppath(), $filename);
file_put_contents($tempfile, json_encode(['argv' => $a->argv, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
logger('Incoming message stored under ' . $tempfile);
Logger::log('Incoming message stored under ' . $tempfile);
*/
if (!empty($a->argv[1])) {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);

View file

@ -10,6 +10,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Authentication;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\User;
@ -146,7 +147,7 @@ class Login extends BaseModule
);
}
} catch (Exception $e) {
logger('authenticate: failed login attempt: ' . notags($username) . ' from IP ' . $_SERVER['REMOTE_ADDR']);
Logger::log('authenticate: failed login attempt: ' . notags($username) . ' from IP ' . $_SERVER['REMOTE_ADDR']);
info('Login failed. Please check your credentials.' . EOL);
$a->internalRedirect();
}
@ -195,7 +196,7 @@ class Login extends BaseModule
);
if (DBA::isResult($user)) {
if ($data->hash != Authentication::getCookieHashForUser($user)) {
logger("Hash for user " . $data->uid . " doesn't fit.");
Logger::log("Hash for user " . $data->uid . " doesn't fit.");
Authentication::deleteSession();
$a->internalRedirect();
}
@ -231,7 +232,7 @@ class Login extends BaseModule
$check = Config::get('system', 'paranoia');
// extra paranoia - if the IP changed, log them out
if ($check && ($_SESSION['addr'] != $_SERVER['REMOTE_ADDR'])) {
logger('Session address changed. Paranoid setting in effect, blocking session. ' .
Logger::log('Session address changed. Paranoid setting in effect, blocking session. ' .
$_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']);
Authentication::deleteSession();
$a->internalRedirect();

View file

@ -5,9 +5,10 @@
namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Core\System;
use Friendica\Util\HTTPSignature;
use Friendica\Util\Network;
@ -22,9 +23,9 @@ class Magic extends BaseModule
{
$a = self::getApp();
$ret = ['success' => false, 'url' => '', 'message' => ''];
logger('magic mdule: invoked', LOGGER_DEBUG);
Logger::log('magic mdule: invoked', LOGGER_DEBUG);
logger('args: ' . print_r($_REQUEST, true), LOGGER_DATA);
Logger::log('args: ' . print_r($_REQUEST, true), LOGGER_DATA);
$addr = ((x($_REQUEST, 'addr')) ? $_REQUEST['addr'] : '');
$dest = ((x($_REQUEST, 'dest')) ? $_REQUEST['dest'] : '');
@ -41,7 +42,7 @@ class Magic extends BaseModule
}
if (!$cid) {
logger('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG);
Logger::log('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG);
// @TODO Finding a more elegant possibility to redirect to either internal or external URL
$a->redirect($dest);
}
@ -55,7 +56,7 @@ class Magic extends BaseModule
return $ret;
}
logger('Contact is already authenticated', LOGGER_DEBUG);
Logger::log('Contact is already authenticated', LOGGER_DEBUG);
System::externalRedirect($dest);
}

View file

@ -5,6 +5,7 @@
namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
@ -57,8 +58,8 @@ class Owa extends BaseModule
$verified = HTTPSignature::verifyMagic($contact['pubkey']);
if ($verified && $verified['header_signed'] && $verified['header_valid']) {
logger('OWA header: ' . print_r($verified, true), LOGGER_DATA);
logger('OWA success: ' . $contact['addr'], LOGGER_DATA);
Logger::log('OWA header: ' . print_r($verified, true), LOGGER_DATA);
Logger::log('OWA success: ' . $contact['addr'], LOGGER_DATA);
$ret['success'] = true;
$token = random_string(32);
@ -75,10 +76,10 @@ class Owa extends BaseModule
openssl_public_encrypt($token, $result, $contact['pubkey']);
$ret['encrypted_token'] = base64url_encode($result);
} else {
logger('OWA fail: ' . $contact['id'] . ' ' . $contact['addr'] . ' ' . $contact['url'], LOGGER_DEBUG);
Logger::log('OWA fail: ' . $contact['id'] . ' ' . $contact['addr'] . ' ' . $contact['url'], LOGGER_DEBUG);
}
} else {
logger('Contact not found: ' . $handle, LOGGER_DEBUG);
Logger::log('Contact not found: ' . $handle, LOGGER_DEBUG);
}
}
}