diff options
author | Simon Rettberg | 2019-12-07 13:51:46 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-12-07 13:51:46 +0100 |
commit | 994a9de00b76430976bafe79234393be9ed01b52 (patch) | |
tree | 5db9ea42619db6a0380d0bd2b5107f0194d6bc43 /apis/cron.inc.php | |
parent | Merge branch 'master' into wol (diff) | |
download | slx-admin-994a9de00b76430976bafe79234393be9ed01b52.tar.gz slx-admin-994a9de00b76430976bafe79234393be9ed01b52.tar.xz slx-admin-994a9de00b76430976bafe79234393be9ed01b52.zip |
[apis/cron] Simple logging function for debugging
Diffstat (limited to 'apis/cron.inc.php')
-rw-r--r-- | apis/cron.inc.php | 22 |
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()); |