Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/logreader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2018-04-25 13:41:45 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2018-04-25 13:41:55 +0300
commitbd38d77e9277aa5c61b6cd661bfddd339f119b4a (patch)
tree71db55e4abbd12f8ccb0ca610cf6a157b91aca34 /lib
parent9b8cf5937707fed48aa7b40d6c10109ee056309d (diff)
adjust to changes from server/#9293
most old static classes are gone, and essentially there is just one standard log file (if in use). Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/LogController.php29
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/Controller/LogController.php b/lib/Controller/LogController.php
index f0ab2fc..c77cba7 100644
--- a/lib/Controller/LogController.php
+++ b/lib/Controller/LogController.php
@@ -28,6 +28,8 @@ use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IRequest;
+use OCP\Log\IFileBased;
+use OCP\Log\ILogFactory;
/**
* Class LogController
@@ -39,26 +41,33 @@ class LogController extends Controller {
* @var IConfig
*/
private $config;
+ /** @var ILogFactory */
+ private $logFactory;
public function __construct($appName,
IRequest $request,
- IConfig $config) {
+ IConfig $config,
+ ILogFactory $logFactory
+ ) {
parent::__construct($appName, $request);
$this->config = $config;
+ $this->logFactory = $logFactory;
}
+ /**
+ * @return LogIterator
+ * @throws \Exception
+ */
private function getLogIterator() {
$dateFormat = $this->config->getSystemValue('logdateformat', \DateTime::ATOM);
$timezone = $this->config->getSystemValue('logtimezone', 'UTC');
- $logClasses = ['\OC\Log\Owncloud', '\OC_Log_Owncloud', '\OC\Log\File'];
- foreach ($logClasses as $logClass) {
- if (class_exists($logClass)) {
- $handle = fopen($logClass::getLogFilePath(), 'rb');
- if ($handle) {
- return new LogIterator($handle, $dateFormat, $timezone);
- } else {
- throw new \Exception("Error while opening " . $logClass::getLogFilePath());
- }
+ $log = $this->logFactory->get('file');
+ if($log instanceof IFileBased) {
+ $handle = fopen($log->getLogFilePath(), 'rb');
+ if ($handle) {
+ return new LogIterator($handle, $dateFormat, $timezone);
+ } else {
+ throw new \Exception("Error while opening " . $log->getLogFilePath());
}
}
throw new \Exception('Can\'t find log class');