summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Log/File.php17
-rw-r--r--lib/private/Log/LogFactory.php24
-rw-r--r--lib/private/Server.php7
3 files changed, 20 insertions, 28 deletions
diff --git a/lib/private/Log/File.php b/lib/private/Log/File.php
index 86f57f78fda..597cb54e402 100644
--- a/lib/private/Log/File.php
+++ b/lib/private/Log/File.php
@@ -36,10 +36,9 @@
*/
namespace OC\Log;
-use OCP\IConfig;
+use OC\SystemConfig;
use OCP\Log\IFileBased;
use OCP\Log\IWriter;
-
use OCP\ILogger;
/**
@@ -51,10 +50,10 @@ use OCP\ILogger;
class File implements IWriter, IFileBased {
/** @var string */
protected $logFile;
- /** @var IConfig */
+ /** @var SystemConfig */
private $config;
- public function __construct(string $path, string $fallbackPath = '', IConfig $config) {
+ public function __construct(string $path, string $fallbackPath = '', SystemConfig $config) {
$this->logFile = $path;
if (!file_exists($this->logFile)) {
if(
@@ -78,8 +77,8 @@ class File implements IWriter, IFileBased {
*/
public function write(string $app, $message, int $level) {
// default to ISO8601
- $format = $this->config->getSystemValue('logdateformat', \DateTime::ATOM);
- $logTimeZone = $this->config->getSystemValue('logtimezone', 'UTC');
+ $format = $this->config->getValue('logdateformat', \DateTime::ATOM);
+ $logTimeZone = $this->config->getValue('logtimezone', 'UTC');
try {
$timezone = new \DateTimeZone($logTimeZone);
} catch (\Exception $e) {
@@ -99,7 +98,7 @@ class File implements IWriter, IFileBased {
$time = $time->format($format);
$url = ($request->getRequestUri() !== '') ? $request->getRequestUri() : '--';
$method = is_string($request->getMethod()) ? $request->getMethod() : '--';
- if($this->config->getSystemValue('installed', false)) {
+ if($this->config->getValue('installed', false)) {
$user = \OC_User::getUser() ? \OC_User::getUser() : '--';
} else {
$user = '--';
@@ -108,7 +107,7 @@ class File implements IWriter, IFileBased {
if ($userAgent === '') {
$userAgent = '--';
}
- $version = $this->config->getSystemValue('version', '');
+ $version = $this->config->getValue('version', '');
$entry = compact(
'reqId',
'level',
@@ -157,7 +156,7 @@ class File implements IWriter, IFileBased {
* @return array
*/
public function getEntries(int $limit=50, int $offset=0):array {
- $minLevel = $this->config->getSystemValue("loglevel", ILogger::WARN);
+ $minLevel = $this->config->getValue("loglevel", ILogger::WARN);
$entries = array();
$handle = @fopen($this->logFile, 'rb');
if ($handle) {
diff --git a/lib/private/Log/LogFactory.php b/lib/private/Log/LogFactory.php
index 63f08a32320..9b9d12abfa8 100644
--- a/lib/private/Log/LogFactory.php
+++ b/lib/private/Log/LogFactory.php
@@ -23,8 +23,8 @@
namespace OC\Log;
-use OC\AllConfig;
use OC\Log;
+use OC\SystemConfig;
use OCP\ILogger;
use OCP\IServerContainer;
use OCP\Log\ILogFactory;
@@ -33,14 +33,15 @@ use OCP\Log\IWriter;
class LogFactory implements ILogFactory {
/** @var IServerContainer */
private $c;
+ /** @var SystemConfig */
+ private $systemConfig;
- public function __construct(IServerContainer $c) {
+ public function __construct(IServerContainer $c, SystemConfig $systemConfig) {
$this->c = $c;
+ $this->systemConfig = $systemConfig;
}
/**
- * @param $type
- * @return \OC\Log\Errorlog|File|\stdClass
* @throws \OCP\AppFramework\QueryException
*/
public function get(string $type):IWriter {
@@ -61,24 +62,17 @@ class LogFactory implements ILogFactory {
}
public function getCustomLogger(string $path):ILogger {
- $systemConfig = null;
- $iconfig = $this->c->getConfig();
- if($iconfig instanceof AllConfig) {
- // Log is bound to SystemConfig, but fetches it from \OC::$server if not supplied
- $systemConfig = $iconfig->getSystemConfig();
- }
$log = $this->buildLogFile($path);
- return new Log($log, $systemConfig);
+ return new Log($log, $this->systemConfig);
}
protected function buildLogFile(string $logFile = ''):File {
- $config = $this->c->getConfig();
- $defaultLogFile = $config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log';
+ $defaultLogFile = $this->systemConfig->getValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log';
if($logFile === '') {
- $logFile = $config->getSystemValue('logfile', $defaultLogFile);
+ $logFile = $this->systemConfig->getValue('logfile', $defaultLogFile);
}
$fallback = $defaultLogFile !== $logFile ? $defaultLogFile : '';
- return new File($logFile, $fallback, $config);
+ return new File($logFile, $fallback, $this->systemConfig);
}
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index c744ba37ded..a879c65bb9b 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -548,7 +548,7 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService(\OCP\ILogger::class, function (Server $c) {
$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
- $factory = new LogFactory($c);
+ $factory = new LogFactory($c, $this->getSystemConfig());
$logger = $factory->get($logType);
$registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
@@ -557,9 +557,8 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerAlias('Logger', \OCP\ILogger::class);
$this->registerService(ILogFactory::class, function (Server $c) {
- return new LogFactory($c);
+ return new LogFactory($c, $this->getSystemConfig());
});
- $this->registerAlias('LogFactory', ILogFactory::class);
$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
$config = $c->getConfig();
@@ -1539,7 +1538,7 @@ class Server extends ServerContainer implements IServerContainer {
* @throws \OCP\AppFramework\QueryException
*/
public function getLogFactory() {
- return $this->query('LogFactory');
+ return $this->query(ILogFactory::class);
}
/**