mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 10:40:40 -04:00
Merge pull request #58750 from nextcloud/jtr/migrate-AuditLogger-to-IAppConfig
refactor(admin_audit): migrate to IAppConfig
This commit is contained in:
commit
e99befd96f
4 changed files with 11 additions and 18 deletions
|
|
@ -53,9 +53,7 @@ use OCP\Group\Events\GroupCreatedEvent;
|
|||
use OCP\Group\Events\GroupDeletedEvent;
|
||||
use OCP\Group\Events\UserAddedEvent;
|
||||
use OCP\Group\Events\UserRemovedEvent;
|
||||
use OCP\IConfig;
|
||||
use OCP\Log\Audit\CriticalActionPerformedEvent;
|
||||
use OCP\Log\ILogFactory;
|
||||
use OCP\Preview\BeforePreviewFetchedEvent;
|
||||
use OCP\Share;
|
||||
use OCP\Share\Events\ShareCreatedEvent;
|
||||
|
|
@ -81,9 +79,7 @@ class Application extends App implements IBootstrap {
|
|||
|
||||
#[\Override]
|
||||
public function register(IRegistrationContext $context): void {
|
||||
$context->registerService(IAuditLogger::class, function (ContainerInterface $c) {
|
||||
return new AuditLogger($c->get(ILogFactory::class), $c->get(IConfig::class));
|
||||
});
|
||||
$context->registerServiceAlias(IAuditLogger::class, AuditLogger::class);
|
||||
|
||||
$context->registerEventListener(CriticalActionPerformedEvent::class, CriticalActionPerformedEventListener::class);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\AdminAudit;
|
||||
|
||||
use OCP\AppFramework\Services\IAppConfig;
|
||||
use OCP\IConfig;
|
||||
use OCP\Log\ILogFactory;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
|
@ -20,7 +21,11 @@ class AuditLogger implements IAuditLogger {
|
|||
|
||||
private LoggerInterface $parentLogger;
|
||||
|
||||
public function __construct(ILogFactory $logFactory, IConfig $config) {
|
||||
public function __construct(
|
||||
ILogFactory $logFactory,
|
||||
IAppConfig $appConfig,
|
||||
IConfig $config,
|
||||
) {
|
||||
$auditType = $config->getSystemValueString('log_type_audit', 'file');
|
||||
$defaultTag = $config->getSystemValueString('syslog_tag', 'Nextcloud');
|
||||
$auditTag = $config->getSystemValueString('syslog_tag_audit', $defaultTag);
|
||||
|
|
@ -29,7 +34,7 @@ class AuditLogger implements IAuditLogger {
|
|||
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);
|
||||
$logFile = $appConfig->getAppValueString('logfile', $default);
|
||||
}
|
||||
|
||||
$this->parentLogger = $logFactory->getCustomPsrLogger($logFile, $auditType, $auditTag);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\AdminAudit\BackgroundJobs;
|
||||
|
||||
use OCP\AppFramework\Services\IAppConfig;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCP\IConfig;
|
||||
|
|
@ -18,6 +19,7 @@ class Rotate extends TimedJob {
|
|||
|
||||
public function __construct(
|
||||
ITimeFactory $time,
|
||||
private IAppConfig $appConfig,
|
||||
private IConfig $config,
|
||||
) {
|
||||
parent::__construct($time);
|
||||
|
|
@ -28,7 +30,7 @@ class Rotate extends TimedJob {
|
|||
#[\Override]
|
||||
protected function run($argument): void {
|
||||
$default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
|
||||
$this->filePath = $this->config->getAppValue('admin_audit', 'logfile', $default);
|
||||
$this->filePath = $this->appConfig->getAppValueString('logfile', $default);
|
||||
|
||||
if ($this->filePath === '') {
|
||||
// default log file, nothing to do
|
||||
|
|
|
|||
|
|
@ -20,16 +20,6 @@
|
|||
<code><![CDATA[Util::connectHook(Share::class, 'share_link_access', $shareActions, 'shareAccessed')]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="apps/admin_audit/lib/AuditLogger.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[getAppValue]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="apps/admin_audit/lib/BackgroundJobs/Rotate.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[getAppValue]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="apps/cloud_federation_api/lib/Controller/RequestHandlerController.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Util::emitHook(
|
||||
|
|
|
|||
Loading…
Reference in a new issue