diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-04-25 02:27:43 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-04-26 12:10:52 +0200 |
commit | cfc3ab0119d23a4c8ccccefb13d2271b0c0675ae (patch) | |
tree | dfab8e9dd20412ce46d21eeb42861854193ca56f /lib/private/Log/LogFactory.php | |
parent | 5fbf184134f34633bc150b2e0210c4a97ec285a9 (diff) | |
download | nextcloud-server-cfc3ab0119d23a4c8ccccefb13d2271b0c0675ae.tar.gz nextcloud-server-cfc3ab0119d23a4c8ccccefb13d2271b0c0675ae.zip |
offer API to create own File log. admin_audit makes use of it
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Log/LogFactory.php')
-rw-r--r-- | lib/private/Log/LogFactory.php | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/private/Log/LogFactory.php b/lib/private/Log/LogFactory.php index 13049083fee..c1a4d00ceaa 100644 --- a/lib/private/Log/LogFactory.php +++ b/lib/private/Log/LogFactory.php @@ -23,9 +23,13 @@ namespace OC\Log; +use OC\Log; +use OCP\ILogger; use OCP\IServerContainer; +use OCP\Log\ILogFactory; +use OCP\Log\IWriter; -class LogFactory { +class LogFactory implements ILogFactory { /** @var IServerContainer */ private $c; @@ -38,7 +42,7 @@ class LogFactory { * @return \OC\Log\Errorlog|File|\stdClass * @throws \OCP\AppFramework\QueryException */ - public function get($type) { + public function get(string $type):IWriter { switch (strtolower($type)) { case 'errorlog': return new Errorlog(); @@ -51,16 +55,23 @@ class LogFactory { case 'owncloud': case 'nextcloud': default: - return $this->buildLogFile(); + return $this->buildLogFile(); } } - protected function buildLogFile() { + public function getCustomLogger(string $path):ILogger { + $log = $this->buildLogFile($path); + return new Log($log, $this->c->getConfig()); + } + + protected function buildLogFile(string $logFile = ''):File { $config = $this->c->getConfig(); $defaultLogFile = $config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log'; - $logFile = $config->getSystemValue('logfile', $defaultLogFile); + if($logFile === '') { + $logFile = $config->getSystemValue('logfile', $defaultLogFile); + } $fallback = $defaultLogFile !== $logFile ? $defaultLogFile : ''; - return new File($logFile, $fallback); + return new File($logFile, $fallback, $config); } } |