Replace Logger with DI::logger() in Model Post classes

This commit is contained in:
Art4 2025-01-13 09:51:46 +00:00
parent 615f96012f
commit 39448160f1
8 changed files with 63 additions and 71 deletions

View file

@ -7,7 +7,6 @@
namespace Friendica\Model\Post;
use Friendica\Core\Logger;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
@ -53,14 +52,14 @@ class Link
}
if (!in_array(parse_url($url, PHP_URL_SCHEME), ['http', 'https'])) {
Logger::info('Bad URL, quitting', ['uri-id' => $uriId, 'url' => $url]);
DI::logger()->info('Bad URL, quitting', ['uri-id' => $uriId, 'url' => $url]);
return $url;
}
$link = DBA::selectFirst('post-link', ['id'], ['uri-id' => $uriId, 'url' => $url]);
if (!empty($link['id'])) {
$id = $link['id'];
Logger::info('Found', ['id' => $id, 'uri-id' => $uriId, 'url' => $url]);
DI::logger()->info('Found', ['id' => $id, 'uri-id' => $uriId, 'url' => $url]);
} else {
$fields = self::fetchMimeType($url);
$fields['uri-id'] = $uriId;
@ -68,7 +67,7 @@ class Link
DBA::insert('post-link', $fields, Database::INSERT_IGNORE);
$id = DBA::lastInsertId();
Logger::info('Inserted', $fields);
DI::logger()->info('Inserted', $fields);
}
if (empty($id)) {
@ -114,12 +113,12 @@ class Link
try {
$curlResult = HTTPSignature::fetchRaw($url, 0, [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => $accept]);
} catch (\Exception $exception) {
Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
DI::logger()->notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
return [];
}
if (!$curlResult->isSuccess()) {
Logger::notice('Fetching unsuccessful', ['url' => $url]);
DI::logger()->notice('Fetching unsuccessful', ['url' => $url]);
return [];
}