Make it easy to check for $debug condition for c_echo

This commit is contained in:
Tony Murray
2016-08-17 16:00:43 -05:00
parent 21514f1b69
commit 4f1a50a36e
2 changed files with 8 additions and 8 deletions
+5 -1
View File
@@ -628,9 +628,13 @@ function d_echo($text, $no_debug_text = null) {
* https://github.com/pear/Console_Color2/blob/master/examples/documentation
*
* @param string $string the string to print with console color
* @param bool $enabled if set to false, this function does nothing
*/
function c_echo($string)
function c_echo($string, $enabled = true)
{
if(!$enabled) {
return;
}
global $console_color;
if($console_color) {
+3 -7
View File
@@ -172,21 +172,17 @@ function rrdtool($command, $filename, $options, $timeout = 0)
$cmd = "$command $filename $options";
}
if ($debug) {
c_echo('RRD[%g'.$cmd."%n] \n"));
}
c_echo("RRD[%g$cmd%n]\n", $debug);
// do not write rrd files, but allow read-only commands
if ($config['norrd'] && !in_array($command,
array('graph', 'graphv', 'dump', 'fetch', 'first', 'last', 'lastupdate', 'info', 'xport'))
) {
c_echo('[%rRRD Disabled%n]');
c_echo("[%rRRD Disabled%n]\n");
$output = array(null, null);
} elseif ($command == 'create' && version_compare($config['rrdtool_version'], '1.5', '<') && is_file($filename)) {
// do not overwrite RRD if it already exists and RRDTool ver. < 1.5
if ($debug) {
c_echo('RRD[%g' . $filename . " already exists%n]\n"));
}
c_echo("RRD[%g$filename already exists%n]\n", $debug);
$output = array(null, null);
} else {
if ($timeout > 0 && stream_select($r = $rrd_pipes, $w = null, $x = null, 0)) {