diff --git a/includes/common.php b/includes/common.php index c6eba819e3..413cae5671 100644 --- a/includes/common.php +++ b/includes/common.php @@ -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) { diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 8349da60ce..18c8ea4497 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -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)) {