Move admin_audit to LoggerInterface
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
c7c5150ddb
commit
5ec2323f25
|
@ -29,16 +29,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\AdminAudit\Actions;
|
||||
|
||||
use OCP\ILogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Action {
|
||||
/** @var ILogger */
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* @param ILogger $logger
|
||||
*/
|
||||
public function __construct(ILogger $logger) {
|
||||
public function __construct(LoggerInterface $logger) {
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,19 +58,19 @@ use OCP\Authentication\TwoFactorAuth\IProvider;
|
|||
use OCP\Console\ConsoleEvent;
|
||||
use OCP\IConfig;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\ILogger;
|
||||
use OCP\IPreview;
|
||||
use OCP\IServerContainer;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Log\ILogFactory;
|
||||
use OCP\Share;
|
||||
use OCP\Util;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
|
||||
/** @var ILogger */
|
||||
/** @var LoggerInterface */
|
||||
protected $logger;
|
||||
|
||||
public function __construct() {
|
||||
|
@ -81,7 +81,7 @@ class Application extends App implements IBootstrap {
|
|||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
/** @var ILogger $logger */
|
||||
/** @var LoggerInterface $logger */
|
||||
$logger = $context->injectFn(
|
||||
Closure::fromCallable([$this, 'getLogger'])
|
||||
);
|
||||
|
@ -94,21 +94,21 @@ class Application extends App implements IBootstrap {
|
|||
}
|
||||
|
||||
private function getLogger(IConfig $config,
|
||||
ILogger $logger,
|
||||
ILogFactory $logFactory): ILogger {
|
||||
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;
|
||||
}
|
||||
return $logFactory->getCustomLogger($logFile);
|
||||
return $logFactory->getCustomPsrLogger($logFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks in order to log them
|
||||
*/
|
||||
private function registerHooks(ILogger $logger,
|
||||
private function registerHooks(LoggerInterface $logger,
|
||||
IServerContainer $serverContainer) {
|
||||
$this->userManagementHooks($logger, $serverContainer->get(IUserSession::class));
|
||||
$this->groupHooks($logger, $serverContainer->get(IGroupManager::class));
|
||||
|
@ -128,7 +128,7 @@ class Application extends App implements IBootstrap {
|
|||
$this->securityHooks($logger, $eventDispatcher);
|
||||
}
|
||||
|
||||
private function userManagementHooks(ILogger $logger,
|
||||
private function userManagementHooks(LoggerInterface $logger,
|
||||
IUserSession $userSession) {
|
||||
$userActions = new UserManagement($logger);
|
||||
|
||||
|
@ -142,7 +142,7 @@ class Application extends App implements IBootstrap {
|
|||
$userSession->listen('\OC\User', 'postUnassignedUserId', [$userActions, 'unassign']);
|
||||
}
|
||||
|
||||
private function groupHooks(ILogger $logger,
|
||||
private function groupHooks(LoggerInterface $logger,
|
||||
IGroupManager $groupManager) {
|
||||
$groupActions = new GroupManagement($logger);
|
||||
|
||||
|
@ -153,7 +153,7 @@ class Application extends App implements IBootstrap {
|
|||
$groupManager->listen('\OC\Group', 'postCreate', [$groupActions, 'createGroup']);
|
||||
}
|
||||
|
||||
private function sharingHooks(ILogger $logger) {
|
||||
private function sharingHooks(LoggerInterface $logger) {
|
||||
$shareActions = new Sharing($logger);
|
||||
|
||||
Util::connectHook(Share::class, 'post_shared', $shareActions, 'shared');
|
||||
|
@ -165,7 +165,7 @@ class Application extends App implements IBootstrap {
|
|||
Util::connectHook(Share::class, 'share_link_access', $shareActions, 'shareAccessed');
|
||||
}
|
||||
|
||||
private function authHooks(ILogger $logger) {
|
||||
private function authHooks(LoggerInterface $logger) {
|
||||
$authActions = new Auth($logger);
|
||||
|
||||
Util::connectHook('OC_User', 'pre_login', $authActions, 'loginAttempt');
|
||||
|
@ -173,7 +173,7 @@ class Application extends App implements IBootstrap {
|
|||
Util::connectHook('OC_User', 'logout', $authActions, 'logout');
|
||||
}
|
||||
|
||||
private function appHooks(ILogger $logger,
|
||||
private function appHooks(LoggerInterface $logger,
|
||||
EventDispatcherInterface $eventDispatcher) {
|
||||
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function (ManagerEvent $event) use ($logger) {
|
||||
$appActions = new AppManagement($logger);
|
||||
|
@ -189,7 +189,7 @@ class Application extends App implements IBootstrap {
|
|||
});
|
||||
}
|
||||
|
||||
private function consoleHooks(ILogger $logger,
|
||||
private function consoleHooks(LoggerInterface $logger,
|
||||
EventDispatcherInterface $eventDispatcher) {
|
||||
$eventDispatcher->addListener(ConsoleEvent::EVENT_RUN, function (ConsoleEvent $event) use ($logger) {
|
||||
$appActions = new Console($logger);
|
||||
|
@ -197,7 +197,7 @@ class Application extends App implements IBootstrap {
|
|||
});
|
||||
}
|
||||
|
||||
private function fileHooks(ILogger $logger,
|
||||
private function fileHooks(LoggerInterface $logger,
|
||||
EventDispatcherInterface $eventDispatcher) {
|
||||
$fileActions = new Files($logger);
|
||||
$eventDispatcher->addListener(
|
||||
|
@ -259,19 +259,19 @@ class Application extends App implements IBootstrap {
|
|||
);
|
||||
}
|
||||
|
||||
private function versionsHooks(ILogger $logger) {
|
||||
private function versionsHooks(LoggerInterface $logger) {
|
||||
$versionsActions = new Versions($logger);
|
||||
Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback');
|
||||
Util::connectHook('\OCP\Versions', 'delete', $versionsActions, 'delete');
|
||||
}
|
||||
|
||||
private function trashbinHooks(ILogger $logger) {
|
||||
private function trashbinHooks(LoggerInterface $logger) {
|
||||
$trashActions = new Trashbin($logger);
|
||||
Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete');
|
||||
Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore');
|
||||
}
|
||||
|
||||
private function securityHooks(ILogger $logger,
|
||||
private function securityHooks(LoggerInterface $logger,
|
||||
EventDispatcherInterface $eventDispatcher) {
|
||||
$eventDispatcher->addListener(IProvider::EVENT_SUCCESS, function (GenericEvent $event) use ($logger) {
|
||||
$security = new Security($logger);
|
||||
|
|
Loading…
Reference in New Issue