Skip to content

Commit 6b3a9e0

Browse files
committed
Component/Logging: contribute cron jobs
1 parent ec210c0 commit 6b3a9e0

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

components/ILIAS/Logging/Logging.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,11 @@ public function init(
3636
new \ilLoggingSetupAgent(
3737
$pull[\ILIAS\Refinery\Factory::class]
3838
);
39+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
40+
new \ilLoggerCronCleanErrorFiles(
41+
'components\\' . self::class,
42+
$use[\ILIAS\Language\Language::class],
43+
true
44+
);
3945
}
4046
}

components/ILIAS/Logging/classes/error/class.ilLoggerCronCleanErrorFiles.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
5-
use ILIAS\Cron\Schedule\CronJobScheduleType;
6-
73
/**
84
* This file is part of ILIAS, a powerful learning management system
95
* published by ILIAS open source e-Learning e.V.
@@ -20,20 +16,32 @@
2016
*
2117
*********************************************************************/
2218

19+
declare(strict_types=1);
20+
21+
use ILIAS\Cron\Schedule\CronJobScheduleType;
22+
2323
class ilLoggerCronCleanErrorFiles extends ilCronJob
2424
{
2525
protected const DEFAULT_VALUE_OLDER_THAN = 31;
2626

27-
protected ilLanguage $lng;
2827
protected ilSetting $settings;
2928
protected ilLoggingErrorSettings $error_settings;
3029

31-
public function __construct()
30+
public function __construct(
31+
string $component,
32+
\ILIAS\Language\Language $lng,
33+
bool $registration = false
34+
) {
35+
parent::__construct($component, $lng);
36+
$this->lng->loadLanguageModule('logging');
37+
if (!$registration) {
38+
$this->additionalConstruct();
39+
}
40+
}
41+
42+
private function additionalConstruct()
3243
{
3344
global $DIC;
34-
35-
$this->lng = $DIC->language();
36-
$this->lng->loadLanguageModule("logging");
3745
$this->settings = new ilSetting('log');
3846
$this->error_settings = ilLoggingErrorSettings::getInstance();
3947
}

components/ILIAS/Logging/service.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,5 @@
99
<parent id="adm" max="1">adm</parent>
1010
</object>
1111
</objects>
12-
<crons>
13-
<cron id="log_error_file_cleanup" class="ilLoggerCronCleanErrorFiles" path="Services/Logging/classes/error/" />
14-
</crons>
1512
<logging id="log" />
1613
</service>

0 commit comments

Comments
 (0)