add --debug parameter for froxlor_master_cronjob, thx to nachtgeist for the idea
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -125,6 +125,9 @@ class FileLogger extends AbstractLogger {
|
||||
case LOG_CRIT:
|
||||
$_type = 'critical';
|
||||
break;
|
||||
case LOG_DEBUG:
|
||||
$_type = 'debug';
|
||||
break;
|
||||
default:
|
||||
$_type = 'unknown';
|
||||
break;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user