diff --git a/components/ILIAS/Logging/Logging.php b/components/ILIAS/Logging/Logging.php index c2369d94edf0..f54b812f834c 100644 --- a/components/ILIAS/Logging/Logging.php +++ b/components/ILIAS/Logging/Logging.php @@ -32,15 +32,62 @@ public function init( array | \ArrayAccess &$pull, array | \ArrayAccess &$internal, ): void { + $define[] = \ILIAS\Logging\LoggerFactory::class; + + $implement[\ILIAS\Logging\LoggerFactory::class] = static fn() => + $internal[\ilLoggerFactory::class]; + $contribute[\ILIAS\Setup\Agent::class] = static fn() => new \ilLoggingSetupAgent( $pull[\ILIAS\Refinery\Factory::class] ); $contribute[\ILIAS\Cron\CronJob::class] = static fn() => new \ilLoggerCronCleanErrorFiles( - 'components\\' . self::class, + self::class, $use[\ILIAS\Language\Language::class], - true + $use[\ILIAS\Logging\LoggerFactory::class] ); + $internal[\ilLoggerFactory::class] = static fn() => + \ilLoggerFactory::getInstance( + $internal[\ilLoggingSettings::class] + ); + + $internal[\ilLoggingSettings::class] = static fn() => + new class () implements \ilLoggingSettings { + public function isEnabled(): bool + { + return false; + } + public function getLogDir(): string + { + } + public function getLogFile(): string + { + } + public function getLevel(): int + { + } + public function getLevelByComponent(string $a_component_id): int + { + } + public function getCacheLevel(): int + { + } + public function isCacheEnabled(): bool + { + } + public function isMemoryUsageEnabled(): bool + { + } + public function isBrowserLogEnabled(): bool + { + } + public function isBrowserLogEnabledForUser(string $a_login): bool + { + } + public function getBrowserLogUsers(): array + { + } + }; } } diff --git a/components/ILIAS/Logging/classes/error/class.ilLoggerCronCleanErrorFiles.php b/components/ILIAS/Logging/classes/error/class.ilLoggerCronCleanErrorFiles.php index 4ba01555f120..da29f33ec2f2 100755 --- a/components/ILIAS/Logging/classes/error/class.ilLoggerCronCleanErrorFiles.php +++ b/components/ILIAS/Logging/classes/error/class.ilLoggerCronCleanErrorFiles.php @@ -27,20 +27,10 @@ class ilLoggerCronCleanErrorFiles extends ilCronJob protected ilSetting $settings; protected ilLoggingErrorSettings $error_settings; - public function __construct( - string $component, - \ILIAS\Language\Language $lng, - bool $registration = false - ) { - parent::__construct($component, $lng); + public function init(): void + { $this->lng->loadLanguageModule('logging'); - if (!$registration) { - $this->additionalConstruct(); - } - } - private function additionalConstruct() - { global $DIC; $this->settings = new ilSetting('log'); $this->error_settings = ilLoggingErrorSettings::getInstance(); diff --git a/components/ILIAS/Logging/classes/public/class.ilLoggerFactory.php b/components/ILIAS/Logging/classes/public/class.ilLoggerFactory.php index 497d789f69ed..00633d33bd9a 100755 --- a/components/ILIAS/Logging/classes/public/class.ilLoggerFactory.php +++ b/components/ILIAS/Logging/classes/public/class.ilLoggerFactory.php @@ -28,6 +28,7 @@ use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; use ILIAS\DI\Container; use Monolog\Processor\PsrLogMessageProcessor; +use ILIAS\Logging\LoggerFactory; /** * Logging factory @@ -35,7 +36,7 @@ * @author Stefan Meyer * */ -class ilLoggerFactory +class ilLoggerFactory implements LoggerFactory { protected const DEFAULT_FORMAT = "[%suid%] [%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"; @@ -45,8 +46,7 @@ class ilLoggerFactory private static ?ilLoggerFactory $instance = null; - private ilLoggingSettings $settings; - protected Container $dic; + protected ?Container $dic; private bool $enabled = false; //ToDo PHP8 Review: This is a private var never read only written and should probably be removed. @@ -55,19 +55,21 @@ class ilLoggerFactory */ private array $loggers = array(); - protected function __construct(ilLoggingSettings $settings) - { + protected function __construct( + private ilLoggingSettings $settings + ) { global $DIC; - $this->dic = $DIC; - $this->settings = $settings; $this->enabled = $this->getSettings()->isEnabled(); } - public static function getInstance(): ilLoggerFactory + public static function getInstance(?\ilLoggingSettings $settings = null): ilLoggerFactory { - if (!static::$instance instanceof ilLoggerFactory) { + if (is_null($settings)) { $settings = ilLoggingDBSettings::getInstance(); + static::$instance = null; + } + if (!static::$instance instanceof ilLoggerFactory) { static::$instance = new ilLoggerFactory($settings); } return static::$instance; diff --git a/components/ILIAS/Logging/src/LoggerFactory.php b/components/ILIAS/Logging/src/LoggerFactory.php index bc7a78dcbacf..e99d9ffe4cb9 100644 --- a/components/ILIAS/Logging/src/LoggerFactory.php +++ b/components/ILIAS/Logging/src/LoggerFactory.php @@ -23,5 +23,4 @@ interface LoggerFactory { - }