aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Log/LogFactory.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Log/LogFactory.php')
-rw-r--r--lib/private/Log/LogFactory.php58
1 files changed, 19 insertions, 39 deletions
diff --git a/lib/private/Log/LogFactory.php b/lib/private/Log/LogFactory.php
index a5008f5ef77..c395c31eb98 100644
--- a/lib/private/Log/LogFactory.php
+++ b/lib/private/Log/LogFactory.php
@@ -33,57 +33,37 @@ use OCP\Log\IWriter;
use Psr\Log\LoggerInterface;
class LogFactory implements ILogFactory {
- /** @var IServerContainer */
- private $c;
- /** @var SystemConfig */
- private $systemConfig;
-
- public function __construct(IServerContainer $c, SystemConfig $systemConfig) {
- $this->c = $c;
- $this->systemConfig = $systemConfig;
+ public function __construct(
+ private IServerContainer $c,
+ private SystemConfig $systemConfig,
+ ) {
}
/**
* @throws \OCP\AppFramework\QueryException
*/
public function get(string $type):IWriter {
- switch (strtolower($type)) {
- case 'errorlog':
- return new Errorlog($this->systemConfig);
- case 'syslog':
- return $this->c->resolve(Syslog::class);
- case 'systemd':
- return $this->c->resolve(Systemdlog::class);
- case 'file':
- return $this->buildLogFile();
-
- // Backwards compatibility for old and fallback for unknown log types
- case 'owncloud':
- case 'nextcloud':
- default:
- return $this->buildLogFile();
- }
+ return match (strtolower($type)) {
+ 'errorlog' => new Errorlog($this->systemConfig),
+ 'syslog' => $this->c->resolve(Syslog::class),
+ 'systemd' => $this->c->resolve(Systemdlog::class),
+ 'file' => $this->buildLogFile(),
+ default => $this->buildLogFile(),
+ };
}
- public function getCustomLogger(string $path):ILogger {
+ public function getCustomLogger(string $path): ILogger {
$log = $this->buildLogFile($path);
return new Log($log, $this->systemConfig);
}
protected function createNewLogger(string $type, string $tag, string $path): IWriter {
- switch (strtolower($type)) {
- case 'errorlog':
- return new Errorlog($this->systemConfig, $tag);
- case 'syslog':
- return new Syslog($this->systemConfig, $tag);
- case 'systemd':
- return new Systemdlog($this->systemConfig, $tag);
- case 'file':
- case 'owncloud':
- case 'nextcloud':
- default:
- return $this->buildLogFile($path);
- }
+ return match (strtolower($type)) {
+ 'errorlog' => new Errorlog($this->systemConfig, $tag),
+ 'syslog' => new Syslog($this->systemConfig, $tag),
+ 'systemd' => new Systemdlog($this->systemConfig, $tag),
+ default => $this->buildLogFile($path),
+ };
}
public function getCustomPsrLogger(string $path, string $type = 'file', string $tag = 'Nextcloud'): LoggerInterface {
@@ -93,7 +73,7 @@ class LogFactory implements ILogFactory {
);
}
- protected function buildLogFile(string $logFile = ''):File {
+ protected function buildLogFile(string $logFile = ''): File {
$defaultLogFile = $this->systemConfig->getValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log';
if ($logFile === '') {
$logFile = $this->systemConfig->getValue('logfile', $defaultLogFile);