]> git.mxchange.org Git - friendica.git/commitdiff
Replace Logger with DI::logger() in Contact namespace
authorArt4 <art4@wlabs.de>
Sun, 12 Jan 2025 21:14:33 +0000 (21:14 +0000)
committerArt4 <art4@wlabs.de>
Sun, 12 Jan 2025 21:14:33 +0000 (21:14 +0000)
src/Contact/Avatar.php

index 04f8778a59130c3059866a9d1996616bece00094..5bafa07e2473b0f6de28e324702e41efcf83ea83 100644 (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 '';
                        }
                }