summaryrefslogtreecommitdiffstats
path: root/apis
diff options
context:
space:
mode:
authorSimon Rettberg2019-12-07 13:51:46 +0100
committerSimon Rettberg2019-12-07 13:51:46 +0100
commit994a9de00b76430976bafe79234393be9ed01b52 (patch)
tree5db9ea42619db6a0380d0bd2b5107f0194d6bc43 /apis
parentMerge branch 'master' into wol (diff)
downloadslx-admin-994a9de00b76430976bafe79234393be9ed01b52.tar.gz
slx-admin-994a9de00b76430976bafe79234393be9ed01b52.tar.xz
slx-admin-994a9de00b76430976bafe79234393be9ed01b52.zip
[apis/cron] Simple logging function for debugging
Diffstat (limited to 'apis')
-rw-r--r--apis/cron.inc.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/apis/cron.inc.php b/apis/cron.inc.php
index 75d7f132..d00c179c 100644
--- a/apis/cron.inc.php
+++ b/apis/cron.inc.php
@@ -62,9 +62,25 @@ function getJobStatus($id)
}
// Hooks by other modules
-function handleModule($file)
+/**
+ * @param Hook $hook
+ */
+function handleModule($hook)
{
- include_once $file;
+ global $cron_log_text;
+ $cron_log_text = '';
+ include_once $hook->file;
+ if (!empty($cron_log_text)) {
+ EventLog::info('CronJob ' . $hook->moduleId . ' finished.', $cron_log_text);
+ }
+}
+
+$cron_log_text = '';
+function cron_log($text)
+{
+ // XXX: Enable this code for debugging -- make this configurable some day
+ //global $cron_log_text;
+ //$cron_log_text .= $text . "\n";
}
$blocked = Property::getList(CRON_KEY_BLOCKED);
@@ -93,7 +109,7 @@ foreach (Hook::load('cron') as $hook) {
$value = $hook->moduleId . '|' . time();
Property::addToList(CRON_KEY_STATUS, $value, 30);
try {
- handleModule($hook->file);
+ handleModule($hook);
} catch (Exception $e) {
// Logging
EventLog::failure('Cronjob for module ' . $hook->moduleId . ' has crashed. Check the php or web server error log.', $e->getMessage());