Skip to content

Commit

Permalink
Merge pull request #251 from vitormattos/fix/replace-logger
Browse files Browse the repository at this point in the history
fix: replace logger
  • Loading branch information
PhrozenByte authored Nov 6, 2024
2 parents bd577d2 + d7a4383 commit be21f80
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 44 deletions.
6 changes: 3 additions & 3 deletions lib/Controller/ControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
use OCA\CMSPico\AppInfo\Application;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\ILogger;
use Psr\Log\LoggerInterface;

trait ControllerTrait
{
/** @var ILogger */
/** @var LoggerInterface */
private $logger;

/**
Expand All @@ -42,7 +42,7 @@ trait ControllerTrait
*/
private function createErrorResponse(\Throwable $exception, array $data = []): DataResponse
{
$this->logger->logException($exception, [ 'app' => Application::APP_NAME, 'level' => 2 ]);
$this->logger->error($exception, [ 'app' => Application::APP_NAME, 'level' => 2 ]);

$data['status'] = 0;
if (\OC::$server->getSystemConfig()->getValue('debug', false)) {
Expand Down
12 changes: 6 additions & 6 deletions lib/Controller/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use Psr\Log\LoggerInterface;

class PluginsController extends Controller
{
Expand All @@ -48,12 +48,12 @@ class PluginsController extends Controller
/**
* PluginsController constructor.
*
* @param IRequest $request
* @param IL10N $l10n
* @param ILogger $logger
* @param PluginsService $pluginsService
* @param IRequest $request
* @param IL10N $l10n
* @param LoggerInterface $logger
* @param PluginsService $pluginsService
*/
public function __construct(IRequest $request, IL10N $l10n, ILogger $logger, PluginsService $pluginsService)
public function __construct(IRequest $request, IL10N $l10n, LoggerInterface $logger, PluginsService $pluginsService)
{
parent::__construct(Application::APP_NAME, $request);

Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
use OCA\CMSPico\Service\WebsitesService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\ILogger;
use OCP\IRequest;
use Psr\Log\LoggerInterface;

class SettingsController extends Controller
{
Expand All @@ -43,10 +43,10 @@ class SettingsController extends Controller
* SettingsController constructor.
*
* @param IRequest $request
* @param ILogger $logger
* @param LoggerInterface $logger
* @param WebsitesService $websitesService
*/
public function __construct(IRequest $request, ILogger $logger, WebsitesService $websitesService)
public function __construct(IRequest $request, LoggerInterface $logger, WebsitesService $websitesService)
{
parent::__construct(Application::APP_NAME, $request);

Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/TemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use Psr\Log\LoggerInterface;

class TemplatesController extends Controller
{
Expand All @@ -50,10 +50,10 @@ class TemplatesController extends Controller
*
* @param IRequest $request
* @param IL10N $l10n
* @param ILogger $logger
* @param LoggerInterface $logger
* @param TemplatesService $templatesService
*/
public function __construct(IRequest $request, IL10N $l10n, ILogger $logger, TemplatesService $templatesService)
public function __construct(IRequest $request, IL10N $l10n, LoggerInterface $logger, TemplatesService $templatesService)
{
parent::__construct(Application::APP_NAME, $request);

Expand Down
12 changes: 6 additions & 6 deletions lib/Controller/ThemesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use Psr\Log\LoggerInterface;

class ThemesController extends Controller
{
Expand All @@ -48,12 +48,12 @@ class ThemesController extends Controller
/**
* ThemesController constructor.
*
* @param IRequest $request
* @param IL10N $l10n
* @param ILogger $logger
* @param ThemesService $themesService
* @param IRequest $request
* @param IL10N $l10n
* @param LoggerInterface $logger
* @param ThemesService $themesService
*/
public function __construct(IRequest $request, IL10N $l10n, ILogger $logger, ThemesService $themesService)
public function __construct(IRequest $request, IL10N $l10n, LoggerInterface $logger, ThemesService $themesService)
{
parent::__construct(Application::APP_NAME, $request);

Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/WebsitesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;

class WebsitesController extends Controller
{
Expand All @@ -63,14 +63,14 @@ class WebsitesController extends Controller
* @param IRequest $request
* @param IUserSession $userSession
* @param IL10N $l10n
* @param ILogger $logger
* @param LoggerInterface $logger
* @param WebsitesService $websitesService
*/
public function __construct(
IRequest $request,
IUserSession $userSession,
IL10N $l10n,
ILogger $logger,
LoggerInterface $logger,
WebsitesService $websitesService
) {
parent::__construct(Application::APP_NAME, $request);
Expand Down
6 changes: 3 additions & 3 deletions lib/Migration/AppDataRepairStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
use OCA\CMSPico\Service\WebsitesService;
use OCP\Files\NotFoundException;
use OCP\IGroupManager;
use OCP\ILogger;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use Psr\Log\LoggerInterface;

class AppDataRepairStep implements IRepairStep
{
Expand Down Expand Up @@ -72,7 +72,7 @@ class AppDataRepairStep implements IRepairStep
/**
* AppDataRepairStep constructor.
*
* @param ILogger $logger
* @param LoggerInterface $logger
* @param IGroupManager $groupManager
* @param WebsitesService $websitesService
* @param ConfigService $configService
Expand All @@ -83,7 +83,7 @@ class AppDataRepairStep implements IRepairStep
* @param MiscService $miscService
*/
public function __construct(
ILogger $logger,
LoggerInterface $logger,
IGroupManager $groupManager,
WebsitesService $websitesService,
ConfigService $configService,
Expand Down
12 changes: 6 additions & 6 deletions lib/Migration/MigrationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@
namespace OCA\CMSPico\Migration;

use OCA\CMSPico\AppInfo\Application;
use OCP\ILogger;
use OCP\Migration\IOutput;
use Psr\Log\LoggerInterface;

trait MigrationTrait
{
/** @var ILogger */
/** @var LoggerInterface */
private $logger;

/** @var IOutput */
private $output;

/**
* @param ILogger $logger
* @param LoggerInterface $logger
*/
protected function setLogger(ILogger $logger): void
protected function setLogger(LoggerInterface $logger): void
{
$this->logger = $logger;
}
Expand All @@ -63,7 +63,7 @@ protected function logInfo(string $message, ...$arguments): void
}

$message = sprintf($message, ...$arguments);
$this->logger->log(ILogger::INFO, $message, [ 'app' => Application::APP_NAME ]);
$this->logger->info($message, [ 'app' => Application::APP_NAME ]);
$this->output->info($message);
}

Expand All @@ -78,7 +78,7 @@ protected function logWarning(string $message, ...$arguments): void
}

$message = sprintf($message, ...$arguments);
$this->logger->log(ILogger::WARN, $message, [ 'app' => Application::APP_NAME ]);
$this->logger->warning($message, [ 'app' => Application::APP_NAME ]);
$this->output->warning($message);
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Migration/Version010000From000908.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use OCP\Server;
use Psr\Log\LoggerInterface;

class Version010000From000908 extends SimpleMigrationStep
{
Expand All @@ -62,7 +64,7 @@ class Version010000From000908 extends SimpleMigrationStep
*/
public function __construct()
{
$this->setLogger(\OC::$server->getLogger());
$this->setLogger(Server::get(LoggerInterface::class));

$this->databaseConnection = \OC::$server->getDatabaseConnection();
$this->configService = \OC::$server->query(ConfigService::class);
Expand Down
20 changes: 10 additions & 10 deletions lib/Service/PicoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\ILogger;
use Psr\Log\LoggerInterface;

class PicoService
{
Expand All @@ -67,7 +67,7 @@ class PicoService
/** @var string */
public const CONTENT_EXT = '.md';

/** @var ILogger */
/** @var LoggerInterface */
private $logger;

/** @var AssetsService */
Expand All @@ -88,15 +88,15 @@ class PicoService
/**
* PicoService constructor.
*
* @param ILogger $logger
* @param AssetsService $assetsService
* @param ThemesService $themesService
* @param PluginsService $pluginsService
* @param FileService $fileService
* @param MiscService $miscService
* @param LoggerInterface $logger
* @param AssetsService $assetsService
* @param ThemesService $themesService
* @param PluginsService $pluginsService
* @param FileService $fileService
* @param MiscService $miscService
*/
public function __construct(
ILogger $logger,
LoggerInterface $logger,
AssetsService $assetsService,
ThemesService $themesService,
PluginsService $pluginsService,
Expand Down Expand Up @@ -153,7 +153,7 @@ public function getPage(WebsiteRequest $websiteRequest): PicoPage
throw $e;
} catch (\Exception $e) {
$exception = new PicoRuntimeException($e);
$this->logger->logException($exception, [ 'app' => Application::APP_NAME ]);
$this->logger->error($exception, [ 'app' => Application::APP_NAME ]);
throw $exception;
}

Expand Down

0 comments on commit be21f80

Please sign in to comment.