Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
namespace OCA\Drawio;

use OCP\IConfig;
use OCP\ILogger;

use Psr\Log\LoggerInterface;

class AppConfig {

Expand Down Expand Up @@ -48,7 +47,7 @@ public function __construct($AppName)
$this->appName = $AppName;

$this->config = \OC::$server->getConfig();
$this->logger = \OC::$server->getLogger();
$this->logger = \OC::$server->get(LoggerInterface::class);
}

public function SetDrawioUrl($drawio)
Expand Down
4 changes: 3 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\Node\NodeDeletedEvent;
use OCP\Files\IAppData;
use Psr\Log\LoggerInterface;


class Application extends App {

Expand Down Expand Up @@ -73,7 +75,7 @@ public function __construct(array $urlParams = [])

$container->registerService("Logger", function($c)
{
return $c->query("ServerContainer")->getLogger();
return $c->query("ServerContainer")->get(LoggerInterface::class);
});


Expand Down
21 changes: 11 additions & 10 deletions lib/Controller/EditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
use OCP\Files\FileInfo;
use OCP\Files\IRootFolder;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;

use OC\Files\Filesystem;
use OC\Files\View;
Expand Down Expand Up @@ -100,7 +101,7 @@ class EditorController extends Controller
* @param IUserSession $userSession - current user session
* @param IURLGenerator $urlGenerator - url generator service
* @param IL10N $trans - l10n service
* @param ILogger $logger - logger
* @param LoggerInterface $logger - logger
* @param OCA\Drawio\AppConfig $config - app config
*/
public function __construct($AppName,
Expand All @@ -109,7 +110,7 @@ public function __construct($AppName,
IUserSession $userSession,
IURLGenerator $urlGenerator,
IL10N $trans,
ILogger $logger,
LoggerInterface $logger,
AppConfig $config,
IManager $shareManager,
ISession $session,
Expand Down Expand Up @@ -178,7 +179,7 @@ public function loadFileVersion($fileId, $revId)
{
return $this->loadInternal($fileId, null, true);
} catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Can't load file version: $fileId, $revId", "app" => $this->appName]);
$this->logger->error($e->getMessage(), ["message" => "Can't load file version: $fileId, $revId", "app" => $this->appName, 'level' => LogLevel::ERROR, 'exception' => $e]);
$message = (string)$this->trans->t('An internal server error occurred.');
return new DataResponse(['message' => $message], Http::STATUS_INTERNAL_SERVER_ERROR);
}
Expand Down Expand Up @@ -225,7 +226,7 @@ public function getFileRevisions($fileId)
return new DataResponse(['message' => (string)$this->trans->t('Invalid fileId supplied.')], Http::STATUS_BAD_REQUEST);
}
} catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Can't get file versions: $fileId", "app" => $this->appName]);
$this->logger->error($e->getMessage(), ["message" => "Can't get file versions: $fileId", "app" => $this->appName, 'level' => LogLevel::ERROR, 'exception' => $e]);
$message = (string)$this->trans->t('An internal server error occurred.');
return new DataResponse(['message' => $message], Http::STATUS_INTERNAL_SERVER_ERROR);
}
Expand Down Expand Up @@ -314,7 +315,7 @@ private function loadInternal($fileId, $shareToken, $contentsOnly)
$message = (string)$e->getHint();
return new DataResponse(['message' => $message], Http::STATUS_INTERNAL_SERVER_ERROR);
} catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Can't load file: $fileId , $shareToken", "app" => $this->appName]);
$this->logger->error($e->getMessage(), ["message" => "Can't load file: $fileId , $shareToken", "app" => $this->appName, 'level' => LogLevel::ERROR, 'exception' => $e]);
$message = (string)$this->trans->t('An internal server error occurred.');
return new DataResponse(['message' => $message], Http::STATUS_INTERNAL_SERVER_ERROR);
}
Expand Down Expand Up @@ -382,7 +383,7 @@ public function getFileInfo($fileId, $shareToken)
$message = (string)$e->getHint();
return new DataResponse(['message' => $message], Http::STATUS_INTERNAL_SERVER_ERROR);
} catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Can't get file info: $fileId , $shareToken", "app" => $this->appName]);
$this->logger->error($e->getMessage(), ["message" => "Can't get file info: $fileId , $shareToken", "app" => $this->appName, 'level' => LogLevel::ERROR, 'exception' => $e]);
$message = (string)$this->trans->t('An internal server error occurred.');
return new DataResponse(['message' => $message], Http::STATUS_INTERNAL_SERVER_ERROR);
}
Expand Down Expand Up @@ -486,7 +487,7 @@ public function save($fileId, $shareToken, $fileContents, $etag)
$message = (string)$e->getHint();
return new DataResponse(['message' => $message], Http::STATUS_INTERNAL_SERVER_ERROR);
} catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Can't save file: $fileId , $shareToken", "app" => $this->appName]);
$this->logger->error($e->getMessage(), ["message" => "Can't save file: $fileId , $shareToken", "app" => $this->appName, 'level' => LogLevel::ERROR, 'exception' => $e]);
$message = (string)$this->trans->t('An internal server error occurred.');
return new DataResponse(['message' => $message], Http::STATUS_INTERNAL_SERVER_ERROR);
}
Expand Down Expand Up @@ -539,7 +540,7 @@ public function savePreview($fileId, $shareToken, $previewContents)
}
catch (\Exception $e)
{
$this->logger->logException($e, ["message" => "Can't save preview for file: $fileId , $shareToken", "app" => $this->appName]);
$this->logger->error($e->getMessage(), ["message" => "Can't save preview for file: $fileId , $shareToken", "app" => $this->appName, 'level' => LogLevel::ERROR, 'exception' => $e]);
$message = (string)$this->trans->t('An internal server error occurred.');
return new DataResponse(['message' => $message], Http::STATUS_INTERNAL_SERVER_ERROR);
}
Expand Down Expand Up @@ -576,7 +577,7 @@ public function create($name, $dir)
}
catch (NotPermittedException $e)
{
$this->logger->logException($e, ["message" => "Can't create file: $name", "app" => $this->appName]);
$this->logger->error($e->getMessage(), ["message" => "Can't create file: $name", "app" => $this->appName, 'level' => LogLevel::ERROR, 'exception' => $e]);
return ["error" => $this->trans->t("Can't create file")];
}

Expand Down
7 changes: 4 additions & 3 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;

use OCA\Drawio\AppConfig;
use OCA\Drawio\Migration;
Expand All @@ -33,13 +34,13 @@ class SettingsController extends Controller
* @param string $AppName - application name
* @param IRequest $request - request object
* @param IL10N $trans - l10n service
* @param ILogger $logger - logger
* @param LoggerInterface $logger - logger
* @param OCA\Drawio\AppConfig $config - application configuration
*/
public function __construct($AppName,
IRequest $request,
IL10N $trans,
ILogger $logger,
LoggerInterface $logger,
AppConfig $config
)
{
Expand Down
11 changes: 6 additions & 5 deletions lib/Listeners/FileDeleteListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
use OCP\Files\Folder;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\ILogger;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;

class FileDeleteListener implements IEventListener {

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

/** @var IAppData */
private $appData;

public function __construct(ILogger $logger, IAppData $appData)
public function __construct(LoggerInterface $logger, IAppData $appData)
{
$this->logger = $logger;
$this->appData = $appData;
Expand Down Expand Up @@ -47,7 +48,7 @@ public function handle(Event $event): void {
catch (\Exception $e)
{
// ignore
$this->logger->logException($e, ["message" => "Can't delete preview for file: " . $node->getPath(), "app" => 'drawio']);
$this->logger->error($e->getMessage(), ["message" => "Can't delete preview for file: " . $node->getPath(), "app" => 'drawio', 'level' => LogLevel::ERROR, 'exception' => $e]);
}
}
}
}
9 changes: 5 additions & 4 deletions lib/Preview/DrawioPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
use OCP\Files\FileInfo;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\ILogger;
use OCP\Image;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;

use OCA\Drawio\AppConfig;

Expand All @@ -32,7 +33,7 @@ class DrawioPreview extends Provider
"application/x-drawio-wb"
];

public function __construct(ILogger $logger, IAppData $appData)
public function __construct(LoggerInterface $logger, IAppData $appData)
{
$this->logger = $logger;
$this->appData = $appData;
Expand Down Expand Up @@ -101,8 +102,8 @@ private function getPreviewFile($fileId)
}
catch (\Exception $e)
{
$this->logger->logException($e, ["message" => "Can't get preview file", "app" => $this->appName]);
$this->logger->error($e->getMessage(), ["message" => "Can't get preview file", "app" => $this->appName, 'level' => LogLevel::ERROR, 'exception' => $e]);
return false;
}
}
}
}