diff --git a/lib/classes/logger/class.FileLogger.php b/lib/classes/logger/class.FileLogger.php index 10c9c72b..5e7e881a 100644 --- a/lib/classes/logger/class.FileLogger.php +++ b/lib/classes/logger/class.FileLogger.php @@ -125,6 +125,9 @@ class FileLogger extends AbstractLogger { case LOG_CRIT: $_type = 'critical'; break; + case LOG_DEBUG: + $_type = 'debug'; + break; default: $_type = 'unknown'; break; diff --git a/lib/classes/logger/class.FroxlorLogger.php b/lib/classes/logger/class.FroxlorLogger.php index 6b4a87a0..036b3daa 100644 --- a/lib/classes/logger/class.FroxlorLogger.php +++ b/lib/classes/logger/class.FroxlorLogger.php @@ -40,6 +40,12 @@ class FroxlorLogger { */ static private $loggers = null; + /** + * whether to output log-messages to STDOUT (cron) + * @var bool + */ + static private $crondebug_flag = false; + /** * Class constructor. * @@ -98,6 +104,33 @@ class FroxlorLogger { return; } + if (self::$crondebug_flag) { + switch($type) { + case LOG_INFO: + $_type = 'information'; + break; + case LOG_NOTICE: + $_type = 'notice'; + break; + case LOG_WARNING: + $_type = 'warning'; + break; + case LOG_ERR: + $_type = 'error'; + break; + case LOG_CRIT: + $_type = 'critical'; + break; + case LOG_DEBUG: + $_type = 'debug'; + break; + default: + $_type = 'unknown'; + break; + } + echo "[".$_type."] ".$text.PHP_EOL; + } + if (Settings::Get('logger.log_cron') == '0' && $action == CRON_ACTION ) { @@ -166,4 +199,15 @@ class FroxlorLogger { Settings::Set('logger.log_cron', $_cronlog); return true; } + + /** + * setter for crondebug-flag + * + * @param bool $_flag + * + * @return void + */ + public function setCronDebugFlag($_flag = false) { + self::$crondebug_flag = (bool)$_flag; + } } diff --git a/scripts/froxlor_master_cronjob.php b/scripts/froxlor_master_cronjob.php index 8e2e196e..5db7af5b 100644 --- a/scripts/froxlor_master_cronjob.php +++ b/scripts/froxlor_master_cronjob.php @@ -25,11 +25,12 @@ $lastrun_update = array(); /** * check for --help */ -if (isset($argv[1]) && strtolower($argv[1]) == '--help') { +if (count($argv) < 2 || (isset($argv[1]) && strtolower($argv[1]) == '--help')) { echo "\n*** Froxlor Master Cronjob ***\n\n"; echo "Below are possible parameters for this file\n\n"; - echo "--[cronname]\t\t\tincludes the given cron-file\n"; - echo "--force\t\t\tforces re-generating of config-files (webserver, nameserver, etc.)\n\n"; + echo "--[cronname]\t\tincludes the given cron-file\n"; + echo "--force\t\t\tforces re-generating of config-files (webserver, nameserver, etc.)\n"; + echo "--debug\t\t\toutput debug information about what is going on to STDOUT.\n\n"; } /** @@ -37,6 +38,7 @@ if (isset($argv[1]) && strtolower($argv[1]) == '--help') { * * --[cronname] include [cronname] * --force to include cron_tasks even if it's not its turn + * --debug to output debug information */ for ($x = 1; $x < count($argv); $x++) { // check argument @@ -54,6 +56,9 @@ for ($x = 1; $x < count($argv); $x++) { addToQueue($jobs_to_run, $crontasks); $lastrun_update['tasks'] = $crontasks; } + elseif (strtolower($argv[$x]) == '--debug') { + define('CRON_DEBUG_FLAG', 1); + } // --[cronname] elseif (substr(strtolower($argv[$x]), 0, 2) == '--') { if (strlen($argv[$x]) > 3) { @@ -65,6 +70,8 @@ for ($x = 1; $x < count($argv); $x++) { } } +$cronlog->setCronDebugFlag(defined('CRON_DEBUG_FLAG')); + // do we have anything to include? if (count($jobs_to_run) > 0) { // include all jobs we want to execute