Skip to content

Commit be21f80

Browse files
authored
Merge pull request #251 from vitormattos/fix/replace-logger
fix: replace logger
2 parents bd577d2 + d7a4383 commit be21f80

10 files changed

Lines changed: 46 additions & 44 deletions

lib/Controller/ControllerTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
use OCA\CMSPico\AppInfo\Application;
2828
use OCP\AppFramework\Http;
2929
use OCP\AppFramework\Http\DataResponse;
30-
use OCP\ILogger;
30+
use Psr\Log\LoggerInterface;
3131

3232
trait ControllerTrait
3333
{
34-
/** @var ILogger */
34+
/** @var LoggerInterface */
3535
private $logger;
3636

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

4747
$data['status'] = 0;
4848
if (\OC::$server->getSystemConfig()->getValue('debug', false)) {

lib/Controller/PluginsController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
use OCP\AppFramework\Controller;
3333
use OCP\AppFramework\Http\DataResponse;
3434
use OCP\IL10N;
35-
use OCP\ILogger;
3635
use OCP\IRequest;
36+
use Psr\Log\LoggerInterface;
3737

3838
class PluginsController extends Controller
3939
{
@@ -48,12 +48,12 @@ class PluginsController extends Controller
4848
/**
4949
* PluginsController constructor.
5050
*
51-
* @param IRequest $request
52-
* @param IL10N $l10n
53-
* @param ILogger $logger
54-
* @param PluginsService $pluginsService
51+
* @param IRequest $request
52+
* @param IL10N $l10n
53+
* @param LoggerInterface $logger
54+
* @param PluginsService $pluginsService
5555
*/
56-
public function __construct(IRequest $request, IL10N $l10n, ILogger $logger, PluginsService $pluginsService)
56+
public function __construct(IRequest $request, IL10N $l10n, LoggerInterface $logger, PluginsService $pluginsService)
5757
{
5858
parent::__construct(Application::APP_NAME, $request);
5959

lib/Controller/SettingsController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
use OCA\CMSPico\Service\WebsitesService;
3030
use OCP\AppFramework\Controller;
3131
use OCP\AppFramework\Http\DataResponse;
32-
use OCP\ILogger;
3332
use OCP\IRequest;
33+
use Psr\Log\LoggerInterface;
3434

3535
class SettingsController extends Controller
3636
{
@@ -43,10 +43,10 @@ class SettingsController extends Controller
4343
* SettingsController constructor.
4444
*
4545
* @param IRequest $request
46-
* @param ILogger $logger
46+
* @param LoggerInterface $logger
4747
* @param WebsitesService $websitesService
4848
*/
49-
public function __construct(IRequest $request, ILogger $logger, WebsitesService $websitesService)
49+
public function __construct(IRequest $request, LoggerInterface $logger, WebsitesService $websitesService)
5050
{
5151
parent::__construct(Application::APP_NAME, $request);
5252

lib/Controller/TemplatesController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
use OCP\AppFramework\Controller;
3333
use OCP\AppFramework\Http\DataResponse;
3434
use OCP\IL10N;
35-
use OCP\ILogger;
3635
use OCP\IRequest;
36+
use Psr\Log\LoggerInterface;
3737

3838
class TemplatesController extends Controller
3939
{
@@ -50,10 +50,10 @@ class TemplatesController extends Controller
5050
*
5151
* @param IRequest $request
5252
* @param IL10N $l10n
53-
* @param ILogger $logger
53+
* @param LoggerInterface $logger
5454
* @param TemplatesService $templatesService
5555
*/
56-
public function __construct(IRequest $request, IL10N $l10n, ILogger $logger, TemplatesService $templatesService)
56+
public function __construct(IRequest $request, IL10N $l10n, LoggerInterface $logger, TemplatesService $templatesService)
5757
{
5858
parent::__construct(Application::APP_NAME, $request);
5959

lib/Controller/ThemesController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
use OCP\AppFramework\Controller;
3333
use OCP\AppFramework\Http\DataResponse;
3434
use OCP\IL10N;
35-
use OCP\ILogger;
3635
use OCP\IRequest;
36+
use Psr\Log\LoggerInterface;
3737

3838
class ThemesController extends Controller
3939
{
@@ -48,12 +48,12 @@ class ThemesController extends Controller
4848
/**
4949
* ThemesController constructor.
5050
*
51-
* @param IRequest $request
52-
* @param IL10N $l10n
53-
* @param ILogger $logger
54-
* @param ThemesService $themesService
51+
* @param IRequest $request
52+
* @param IL10N $l10n
53+
* @param LoggerInterface $logger
54+
* @param ThemesService $themesService
5555
*/
56-
public function __construct(IRequest $request, IL10N $l10n, ILogger $logger, ThemesService $themesService)
56+
public function __construct(IRequest $request, IL10N $l10n, LoggerInterface $logger, ThemesService $themesService)
5757
{
5858
parent::__construct(Application::APP_NAME, $request);
5959

lib/Controller/WebsitesController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
use OCP\AppFramework\Controller;
4141
use OCP\AppFramework\Http\DataResponse;
4242
use OCP\IL10N;
43-
use OCP\ILogger;
4443
use OCP\IRequest;
4544
use OCP\IUserSession;
45+
use Psr\Log\LoggerInterface;
4646

4747
class WebsitesController extends Controller
4848
{
@@ -63,14 +63,14 @@ class WebsitesController extends Controller
6363
* @param IRequest $request
6464
* @param IUserSession $userSession
6565
* @param IL10N $l10n
66-
* @param ILogger $logger
66+
* @param LoggerInterface $logger
6767
* @param WebsitesService $websitesService
6868
*/
6969
public function __construct(
7070
IRequest $request,
7171
IUserSession $userSession,
7272
IL10N $l10n,
73-
ILogger $logger,
73+
LoggerInterface $logger,
7474
WebsitesService $websitesService
7575
) {
7676
parent::__construct(Application::APP_NAME, $request);

lib/Migration/AppDataRepairStep.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
use OCA\CMSPico\Service\WebsitesService;
3535
use OCP\Files\NotFoundException;
3636
use OCP\IGroupManager;
37-
use OCP\ILogger;
3837
use OCP\Migration\IOutput;
3938
use OCP\Migration\IRepairStep;
39+
use Psr\Log\LoggerInterface;
4040

4141
class AppDataRepairStep implements IRepairStep
4242
{
@@ -72,7 +72,7 @@ class AppDataRepairStep implements IRepairStep
7272
/**
7373
* AppDataRepairStep constructor.
7474
*
75-
* @param ILogger $logger
75+
* @param LoggerInterface $logger
7676
* @param IGroupManager $groupManager
7777
* @param WebsitesService $websitesService
7878
* @param ConfigService $configService
@@ -83,7 +83,7 @@ class AppDataRepairStep implements IRepairStep
8383
* @param MiscService $miscService
8484
*/
8585
public function __construct(
86-
ILogger $logger,
86+
LoggerInterface $logger,
8787
IGroupManager $groupManager,
8888
WebsitesService $websitesService,
8989
ConfigService $configService,

lib/Migration/MigrationTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@
2525
namespace OCA\CMSPico\Migration;
2626

2727
use OCA\CMSPico\AppInfo\Application;
28-
use OCP\ILogger;
2928
use OCP\Migration\IOutput;
29+
use Psr\Log\LoggerInterface;
3030

3131
trait MigrationTrait
3232
{
33-
/** @var ILogger */
33+
/** @var LoggerInterface */
3434
private $logger;
3535

3636
/** @var IOutput */
3737
private $output;
3838

3939
/**
40-
* @param ILogger $logger
40+
* @param LoggerInterface $logger
4141
*/
42-
protected function setLogger(ILogger $logger): void
42+
protected function setLogger(LoggerInterface $logger): void
4343
{
4444
$this->logger = $logger;
4545
}
@@ -63,7 +63,7 @@ protected function logInfo(string $message, ...$arguments): void
6363
}
6464

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

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

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

lib/Migration/Version010000From000908.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
use OCP\IDBConnection;
3838
use OCP\Migration\IOutput;
3939
use OCP\Migration\SimpleMigrationStep;
40+
use OCP\Server;
41+
use Psr\Log\LoggerInterface;
4042

4143
class Version010000From000908 extends SimpleMigrationStep
4244
{
@@ -62,7 +64,7 @@ class Version010000From000908 extends SimpleMigrationStep
6264
*/
6365
public function __construct()
6466
{
65-
$this->setLogger(\OC::$server->getLogger());
67+
$this->setLogger(Server::get(LoggerInterface::class));
6668

6769
$this->databaseConnection = \OC::$server->getDatabaseConnection();
6870
$this->configService = \OC::$server->query(ConfigService::class);

lib/Service/PicoService.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
use OCP\Files\InvalidPathException;
4343
use OCP\Files\NotFoundException;
4444
use OCP\Files\NotPermittedException;
45-
use OCP\ILogger;
45+
use Psr\Log\LoggerInterface;
4646

4747
class PicoService
4848
{
@@ -67,7 +67,7 @@ class PicoService
6767
/** @var string */
6868
public const CONTENT_EXT = '.md';
6969

70-
/** @var ILogger */
70+
/** @var LoggerInterface */
7171
private $logger;
7272

7373
/** @var AssetsService */
@@ -88,15 +88,15 @@ class PicoService
8888
/**
8989
* PicoService constructor.
9090
*
91-
* @param ILogger $logger
92-
* @param AssetsService $assetsService
93-
* @param ThemesService $themesService
94-
* @param PluginsService $pluginsService
95-
* @param FileService $fileService
96-
* @param MiscService $miscService
91+
* @param LoggerInterface $logger
92+
* @param AssetsService $assetsService
93+
* @param ThemesService $themesService
94+
* @param PluginsService $pluginsService
95+
* @param FileService $fileService
96+
* @param MiscService $miscService
9797
*/
9898
public function __construct(
99-
ILogger $logger,
99+
LoggerInterface $logger,
100100
AssetsService $assetsService,
101101
ThemesService $themesService,
102102
PluginsService $pluginsService,
@@ -153,7 +153,7 @@ public function getPage(WebsiteRequest $websiteRequest): PicoPage
153153
throw $e;
154154
} catch (\Exception $e) {
155155
$exception = new PicoRuntimeException($e);
156-
$this->logger->logException($exception, [ 'app' => Application::APP_NAME ]);
156+
$this->logger->error($exception, [ 'app' => Application::APP_NAME ]);
157157
throw $exception;
158158
}
159159

0 commit comments

Comments
 (0)