summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-03-29 22:25:26 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-04-26 16:50:47 +0200
commit51f04ed5144d4c111970aa976f0ce58ae23e079d (patch)
tree356b46805a8baddddc077a871b3bc629ac85a8d8 /lib/private
parentdffbddcca6fa0221b8f2ac138732cf01154a5187 (diff)
downloadnextcloud-server-51f04ed5144d4c111970aa976f0ce58ae23e079d.tar.gz
nextcloud-server-51f04ed5144d4c111970aa976f0ce58ae23e079d.zip
Move away from deprecated ILogger
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Cache/File.php4
-rw-r--r--lib/private/Dashboard/Manager.php29
-rw-r--r--lib/private/DateTimeZone.php6
3 files changed, 20 insertions, 19 deletions
diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php
index a96a7cd9c0b..8e192b22332 100644
--- a/lib/private/Cache/File.php
+++ b/lib/private/Cache/File.php
@@ -32,8 +32,8 @@ namespace OC\Cache;
use OC\Files\Filesystem;
use OC\Files\View;
use OCP\ICache;
-use OCP\ILogger;
use OCP\Security\ISecureRandom;
+use Psr\Log\LoggerInterface;
class File implements ICache {
@@ -61,7 +61,7 @@ class File implements ICache {
$this->storage = new View('/' . $user->getUID() . '/cache');
return $this->storage;
} else {
- \OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', ILogger::ERROR);
+ \OC::$server->get(LoggerInterface::class)->error('Can\'t get cache storage, user not logged in', ['app' => 'core']);
throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
}
}
diff --git a/lib/private/Dashboard/Manager.php b/lib/private/Dashboard/Manager.php
index a77c389cdeb..9f94a6e8f92 100644
--- a/lib/private/Dashboard/Manager.php
+++ b/lib/private/Dashboard/Manager.php
@@ -30,9 +30,9 @@ use InvalidArgumentException;
use OCP\AppFramework\QueryException;
use OCP\Dashboard\IManager;
use OCP\Dashboard\IWidget;
-use OCP\ILogger;
use OCP\IServerContainer;
use Throwable;
+use Psr\Log\LoggerInterface;
class Manager implements IManager {
@@ -72,10 +72,10 @@ class Manager implements IManager {
* There is a circular dependency between the logger and the registry, so
* we can not inject it. Thus the static call.
*/
- \OC::$server->getLogger()->logException($e, [
- 'message' => 'Could not load lazy dashbaord widget: ' . $e->getMessage(),
- 'level' => ILogger::FATAL,
- ]);
+ \OC::$server->get(LoggerInterface::class)->critical(
+ 'Could not load lazy dashboard widget: ' . $e->getMessage(),
+ ['excepiton' => $e]
+ );
}
/**
* Try to register the loaded reporter. Theoretically it could be of a wrong
@@ -88,10 +88,10 @@ class Manager implements IManager {
* There is a circular dependency between the logger and the registry, so
* we can not inject it. Thus the static call.
*/
- \OC::$server->getLogger()->logException($e, [
- 'message' => 'Could not register lazy dashboard widget: ' . $e->getMessage(),
- 'level' => ILogger::FATAL,
- ]);
+ \OC::$server->get(LoggerInterface::class)->critical(
+ 'Could not register lazy dashboard widget: ' . $e->getMessage(),
+ ['excepiton' => $e]
+ );
}
try {
@@ -100,16 +100,17 @@ class Manager implements IManager {
$endTime = microtime(true);
$duration = $endTime - $startTime;
if ($duration > 1) {
- \OC::$server->getLogger()->error('Dashboard widget {widget} took {duration} seconds to load.', [
+ \OC::$server->get(LoggerInterface::class)->error(
+ 'Dashboard widget {widget} took {duration} seconds to load.', [
'widget' => $widget->getId(),
'duration' => round($duration, 2),
]);
}
} catch (Throwable $e) {
- \OC::$server->getLogger()->logException($e, [
- 'message' => 'Error during dashboard widget loading: ' . $e->getMessage(),
- 'level' => ILogger::FATAL,
- ]);
+ \OC::$server->get(LoggerInterface::class)->critical(
+ 'Error during dashboard widget loading: ' . $e->getMessage(),
+ ['excepiton' => $e]
+ );
}
}
$this->lazyWidgets = [];
diff --git a/lib/private/DateTimeZone.php b/lib/private/DateTimeZone.php
index 49e255c75c8..c514f8d7465 100644
--- a/lib/private/DateTimeZone.php
+++ b/lib/private/DateTimeZone.php
@@ -26,8 +26,8 @@ namespace OC;
use OCP\IConfig;
use OCP\IDateTimeZone;
-use OCP\ILogger;
use OCP\ISession;
+use Psr\Log\LoggerInterface;
class DateTimeZone implements IDateTimeZone {
/** @var IConfig */
@@ -65,7 +65,7 @@ class DateTimeZone implements IDateTimeZone {
try {
return new \DateTimeZone($timeZone);
} catch (\Exception $e) {
- \OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", ILogger::DEBUG);
+ \OC::$server->get(LoggerInterface::class)->debug('Failed to created DateTimeZone "' . $timeZone . '"', ['app' => 'datetimezone']);
return new \DateTimeZone($this->getDefaultTimeZone());
}
}
@@ -110,7 +110,7 @@ class DateTimeZone implements IDateTimeZone {
}
// No timezone found, fallback to UTC
- \OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", ILogger::DEBUG);
+ \OC::$server->get(LoggerInterface::class)->debug('Failed to find DateTimeZone for offset "' . $offset . '"', ['app' => 'datetimezone']);
return new \DateTimeZone($this->getDefaultTimeZone());
}
}