From 497c5841fc60b587dba84dd9ea14e4cccee656fd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 19 Jan 2022 16:16:09 +0100 Subject: Allow write audit log to syslog and systemdlog Signed-off-by: Joas Schilling --- apps/admin_audit/lib/AppInfo/Application.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'apps/admin_audit') diff --git a/apps/admin_audit/lib/AppInfo/Application.php b/apps/admin_audit/lib/AppInfo/Application.php index 7b5fb520bc9..594e1c7f2c4 100644 --- a/apps/admin_audit/lib/AppInfo/Application.php +++ b/apps/admin_audit/lib/AppInfo/Application.php @@ -96,15 +96,19 @@ class Application extends App implements IBootstrap { } private function getLogger(IConfig $config, - LoggerInterface $logger, ILogFactory $logFactory): LoggerInterface { - $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; - $logFile = $config->getAppValue('admin_audit', 'logfile', $default); - - if ($logFile === null) { - return $logger; + $auditType = $config->getSystemValueString('log_type_audit', 'file'); + $defaultTag = $config->getSystemValueString('syslog_tag', 'Nextcloud'); + $auditTag = $config->getSystemValueString('syslog_tag_audit', $defaultTag); + $logFile = $config->getSystemValueString('logfile_audit', ''); + + if ($auditType === 'file' && !$logFile) { + $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; + // Legacy way was appconfig, now it's paralleled with the normal log config + $logFile = $config->getAppValue('admin_audit', 'logfile', $default); } - return $logFactory->getCustomPsrLogger($logFile); + + return $logFactory->getCustomPsrLogger($logFile, $auditType, $auditTag); } /** -- cgit v1.2.3