diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-04-26 23:54:11 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-04-26 23:54:11 +0200 |
commit | aff5fe68b31c3663be2a114666650d2f8723a22b (patch) | |
tree | c5cf285d2f360ef4e44387d996dc89b6476b4d46 /lib/private/Log | |
parent | b841a477c6b96a13ea061df3fc622c3067514bf2 (diff) | |
download | nextcloud-server-aff5fe68b31c3663be2a114666650d2f8723a22b.tar.gz nextcloud-server-aff5fe68b31c3663be2a114666650d2f8723a22b.zip |
use SystemConfig, less dependencies, and not publicly needed
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Log')
-rw-r--r-- | lib/private/Log/File.php | 17 | ||||
-rw-r--r-- | lib/private/Log/LogFactory.php | 24 |
2 files changed, 17 insertions, 24 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); } } |