mirror of
https://github.com/friendica/friendica
synced 2025-01-30 23:39:47 +00:00
Replace Logger with $this->logger in Module classes
This commit is contained in:
parent
105c737609
commit
8643231019
5 changed files with 19 additions and 24 deletions
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Attach as MAttach;
|
||||
|
@ -43,7 +42,7 @@ class Attach extends BaseModule
|
|||
|
||||
$data = MAttach::getData($item);
|
||||
if (is_null($data)) {
|
||||
Logger::notice('NULL data for attachment with id ' . $item['id']);
|
||||
$this->logger->notice('NULL data for attachment with id ' . $item['id']);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Item was not found.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\Content\ContactSelector;
|
|||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Theme;
|
||||
|
@ -121,7 +120,7 @@ class Contact extends BaseModule
|
|||
try {
|
||||
UpdateContact::add(Worker::PRIORITY_HIGH, $contact_id);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Logger::notice($e->getMessage(), ['contact' => $contact]);
|
||||
DI::logger()->notice($e->getMessage(), ['contact' => $contact]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\OpenWebAuthToken;
|
||||
|
@ -60,7 +59,7 @@ class Owa extends BaseModule
|
|||
$verified = HTTPSignature::verifyMagic($contact['pubkey']);
|
||||
|
||||
if ($verified && $verified['header_signed'] && $verified['header_valid']) {
|
||||
Logger::debug('OWA header', ['addr' => $contact['addr'], 'data' => $verified]);
|
||||
$this->logger->debug('OWA header', ['addr' => $contact['addr'], 'data' => $verified]);
|
||||
|
||||
$ret['success'] = true;
|
||||
$token = Strings::getRandomHex(32);
|
||||
|
@ -77,10 +76,10 @@ class Owa extends BaseModule
|
|||
openssl_public_encrypt($token, $result, $contact['pubkey']);
|
||||
$ret['encrypted_token'] = Strings::base64UrlEncode($result);
|
||||
} else {
|
||||
Logger::info('OWA fail', ['id' => $contact['id'], 'addr' => $contact['addr'], 'url' => $contact['url']]);
|
||||
$this->logger->info('OWA fail', ['id' => $contact['id'], 'addr' => $contact['addr'], 'url' => $contact['url']]);
|
||||
}
|
||||
} else {
|
||||
Logger::info('Contact not found', ['handle' => $handle]);
|
||||
$this->logger->info('Contact not found', ['handle' => $handle]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\Contact\Header;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -104,11 +103,11 @@ class Photo extends BaseApi
|
|||
}
|
||||
|
||||
if (empty($id)) {
|
||||
Logger::notice('No picture id was detected', ['parameters' => $this->parameters, 'query' => DI::args()->getQueryString()]);
|
||||
$this->logger->notice('No picture id was detected', ['parameters' => $this->parameters, 'query' => DI::args()->getQueryString()]);
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('The Photo is not available.'));
|
||||
}
|
||||
|
||||
$photo = self::getPhotoById($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL);
|
||||
$photo = $this->getPhotoById($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL);
|
||||
} else {
|
||||
$photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME);
|
||||
$scale = 0;
|
||||
|
@ -172,7 +171,7 @@ class Photo extends BaseApi
|
|||
$data = microtime(true) - $stamp;
|
||||
|
||||
if (empty($imgdata)) {
|
||||
Logger::warning('Invalid photo', ['id' => $photo['id']]);
|
||||
$this->logger->warning('Invalid photo', ['id' => $photo['id']]);
|
||||
if (in_array($photo['backend-class'], [ExternalResource::NAME])) {
|
||||
$reference = json_decode($photo['backend-ref'], true);
|
||||
$error = DI::l10n()->t('Invalid external resource with url %s.', $reference['url']);
|
||||
|
@ -232,7 +231,7 @@ class Photo extends BaseApi
|
|||
$rest = $total - ($fetch + $data + $checksum + $output);
|
||||
|
||||
if (!is_null($scale) && ($scale < 4)) {
|
||||
Logger::debug('Performance:', [
|
||||
$this->logger->debug('Performance:', [
|
||||
'scale' => $scale, 'resource' => $photo['resource-id'],
|
||||
'total' => number_format($total, 3), 'fetch' => number_format($fetch, 3),
|
||||
'data' => number_format($data, 3), 'checksum' => number_format($checksum, 3),
|
||||
|
@ -251,7 +250,7 @@ class Photo extends BaseApi
|
|||
* @param int $customsize Custom size (?)
|
||||
* @return array|bool Array on success, false on error
|
||||
*/
|
||||
private static function getPhotoById(int $id, string $type, int $customsize)
|
||||
private function getPhotoById(int $id, string $type, int $customsize)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'preview':
|
||||
|
@ -359,25 +358,25 @@ class Photo extends BaseApi
|
|||
if ($update) {
|
||||
$curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE, HttpClientOptions::REQUEST => HttpClientRequest::CONTENTTYPE]);
|
||||
$update = !$curlResult->isSuccess() && ($curlResult->getReturnCode() == 404);
|
||||
Logger::debug('Got return code for avatar', ['return code' => $curlResult->getReturnCode(), 'cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
$this->logger->debug('Got return code for avatar', ['return code' => $curlResult->getReturnCode(), 'cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
}
|
||||
if ($update) {
|
||||
try {
|
||||
UpdateContact::add(Worker::PRIORITY_LOW, $id);
|
||||
Logger::info('Invalid file, contact update initiated', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
$this->logger->info('Invalid file, contact update initiated', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Logger::notice($e->getMessage(), ['id' => $id, 'contact' => $contact]);
|
||||
$this->logger->notice($e->getMessage(), ['id' => $id, 'contact' => $contact]);
|
||||
}
|
||||
} else {
|
||||
Logger::info('Invalid file', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
$this->logger->info('Invalid file', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
}
|
||||
}
|
||||
if (!empty($mimetext) && ($mime[0] != 'image') && ($mimetext != 'application/octet-stream')) {
|
||||
Logger::info('Unexpected Content-Type', ['mime' => $mimetext, 'url' => $url]);
|
||||
$this->logger->info('Unexpected Content-Type', ['mime' => $mimetext, 'url' => $url]);
|
||||
$mimetext = '';
|
||||
}
|
||||
if (!empty($mimetext)) {
|
||||
Logger::debug('Expected Content-Type', ['mime' => $mimetext, 'url' => $url]);
|
||||
$this->logger->debug('Expected Content-Type', ['mime' => $mimetext, 'url' => $url]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -89,7 +88,7 @@ class Register extends BaseModule
|
|||
if ($max_dailies) {
|
||||
$count = DBA::count('user', ['`register_date` > UTC_TIMESTAMP - INTERVAL 1 day']);
|
||||
if ($count >= $max_dailies) {
|
||||
Logger::notice('max daily registrations exceeded.');
|
||||
$this->logger->notice('max daily registrations exceeded.');
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.'));
|
||||
return '';
|
||||
}
|
||||
|
@ -250,7 +249,7 @@ class Register extends BaseModule
|
|||
|
||||
// Is there text in the tar pit?
|
||||
if (!empty($arr['email'])) {
|
||||
Logger::info('Tar pit', $arr);
|
||||
$this->logger->info('Tar pit', $arr);
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('You have entered too much information.'));
|
||||
DI::baseUrl()->redirect('register/');
|
||||
}
|
||||
|
@ -273,7 +272,7 @@ class Register extends BaseModule
|
|||
}
|
||||
|
||||
if ($arr['email'] != $arr['repeat']) {
|
||||
Logger::info('Mail mismatch', $arr);
|
||||
$this->logger->info('Mail mismatch', $arr);
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Please enter the identical mail address in the second field.'));
|
||||
$regdata = ['email' => $arr['email'], 'nickname' => $arr['nickname'], 'username' => $arr['username']];
|
||||
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
|
||||
|
|
Loading…
Add table
Reference in a new issue