Replace Logger with DI::logger() in Contact namespace

This commit is contained in:
Art4 2025-01-12 21:14:33 +00:00
parent bf3004e4bf
commit cb7534c823

View file

@ -47,36 +47,36 @@ class Avatar
if (($avatar != $contact['avatar']) || $force) {
self::deleteCache($contact);
Logger::debug('Avatar file name changed', ['new' => $avatar, 'old' => $contact['avatar']]);
DI::logger()->debug('Avatar file name changed', ['new' => $avatar, 'old' => $contact['avatar']]);
} elseif (self::isCacheFile($contact['photo']) && self::isCacheFile($contact['thumb']) && self::isCacheFile($contact['micro'])) {
$fields['photo'] = $contact['photo'];
$fields['thumb'] = $contact['thumb'];
$fields['micro'] = $contact['micro'];
Logger::debug('Using existing cache files', ['uri-id' => $contact['uri-id'], 'fields' => $fields]);
DI::logger()->debug('Using existing cache files', ['uri-id' => $contact['uri-id'], 'fields' => $fields]);
return $fields;
}
try {
$fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
} catch (\Exception $exception) {
Logger::notice('Avatar is invalid', ['avatar' => $avatar, 'exception' => $exception]);
DI::logger()->notice('Avatar is invalid', ['avatar' => $avatar, 'exception' => $exception]);
return $fields;
}
if (!$fetchResult->isSuccess()) {
Logger::debug('Fetching was unsuccessful', ['avatar' => $avatar]);
DI::logger()->debug('Fetching was unsuccessful', ['avatar' => $avatar]);
return $fields;
}
$img_str = $fetchResult->getBodyString();
if (empty($img_str)) {
Logger::debug('Avatar is invalid', ['avatar' => $avatar]);
DI::logger()->debug('Avatar is invalid', ['avatar' => $avatar]);
return $fields;
}
$image = new Image($img_str, $fetchResult->getContentType(), $avatar);
if (!$image->isValid()) {
Logger::debug('Avatar picture is invalid', ['avatar' => $avatar]);
DI::logger()->debug('Avatar picture is invalid', ['avatar' => $avatar]);
return $fields;
}
@ -89,7 +89,7 @@ class Avatar
$fields['thumb'] = self::storeAvatarCache($image, $filename, Proxy::PIXEL_THUMB, $timestamp);
$fields['micro'] = self::storeAvatarCache($image, $filename, Proxy::PIXEL_MICRO, $timestamp);
Logger::debug('Storing new avatar cache', ['uri-id' => $contact['uri-id'], 'fields' => $fields]);
DI::logger()->debug('Storing new avatar cache', ['uri-id' => $contact['uri-id'], 'fields' => $fields]);
return $fields;
}
@ -155,36 +155,36 @@ class Avatar
if (!file_exists($dirpath)) {
if (!@mkdir($dirpath, $dir_perm) && !file_exists($dirpath)) {
Logger::warning('Directory could not be created', ['directory' => $dirpath]);
DI::logger()->warning('Directory could not be created', ['directory' => $dirpath]);
}
} elseif ((($old_perm = fileperms($dirpath) & 0777) != $dir_perm) && !chmod($dirpath, $dir_perm)) {
Logger::warning('Directory permissions could not be changed', ['directory' => $dirpath, 'old' => $old_perm, 'new' => $dir_perm]);
DI::logger()->warning('Directory permissions could not be changed', ['directory' => $dirpath, 'old' => $old_perm, 'new' => $dir_perm]);
}
if ((($old_group = filegroup($dirpath)) != $group) && !chgrp($dirpath, $group)) {
Logger::warning('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]);
DI::logger()->warning('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]);
}
}
if (!file_put_contents($filepath, $image->asString())) {
Logger::warning('File could not be created', ['file' => $filepath]);
DI::logger()->warning('File could not be created', ['file' => $filepath]);
}
$old_perm = fileperms($filepath) & 0666;
$old_group = filegroup($filepath);
if (($old_perm != $file_perm) && !chmod($filepath, $file_perm)) {
Logger::warning('File permissions could not be changed', ['file' => $filepath, 'old' => $old_perm, 'new' => $file_perm]);
DI::logger()->warning('File permissions could not be changed', ['file' => $filepath, 'old' => $old_perm, 'new' => $file_perm]);
}
if (($old_group != $group) && !chgrp($filepath, $group)) {
Logger::warning('File group could not be changed', ['file' => $filepath, 'old' => $old_group, 'new' => $group]);
DI::logger()->warning('File group could not be changed', ['file' => $filepath, 'old' => $old_group, 'new' => $group]);
}
DI::profiler()->stopRecording();
if (!file_exists($filepath)) {
Logger::warning('Avatar cache file could not be stored', ['file' => $filepath]);
DI::logger()->warning('Avatar cache file could not be stored', ['file' => $filepath]);
return '';
}
@ -257,7 +257,7 @@ class Avatar
$localFile = self::getCacheFile($avatar);
if (!empty($localFile)) {
@unlink($localFile);
Logger::debug('Unlink avatar', ['avatar' => $avatar, 'local' => $localFile]);
DI::logger()->debug('Unlink avatar', ['avatar' => $avatar, 'local' => $localFile]);
}
}
@ -277,11 +277,11 @@ class Avatar
if (!file_exists($basepath)) {
// We only automatically create the folder when it is in the web root
if (strpos($basepath, DI::basePath()) !== 0) {
Logger::warning('Base directory does not exist', ['directory' => $basepath]);
DI::logger()->warning('Base directory does not exist', ['directory' => $basepath]);
return '';
}
if (!mkdir($basepath, 0775)) {
Logger::warning('Base directory could not be created', ['directory' => $basepath]);
DI::logger()->warning('Base directory could not be created', ['directory' => $basepath]);
return '';
}
}