diff -r 3b4aef1efff6 -r 3b817b961984 functions.php --- a/functions.php Fri Aug 15 23:31:37 2008 -0400 +++ b/functions.php Fri Aug 15 23:49:00 2008 -0400 @@ -24,23 +24,39 @@ function burnout($msg) { + global $use_colors; $h = @fopen('php://stderr', 'w'); - fwrite($h, "\x1B[31;1m[Greyhound] fatal: \x1B[37;1m"); - fwrite($h, "$msg\x1B[0m\n"); + if ( $use_colors ) + { + fwrite($h, "\x1B[31;1m[Greyhound] fatal: \x1B[37;1m"); + fwrite($h, "$msg\x1B[0m\n"); + } + else + { + fwrite($h, "[Greyhound] fatal: $msg\n"); + } fclose($h); exit(1); } /** - * Print a stylized status message, compatible with Linux consoles + * Print a stylized status message, compatible with Linux consoles. Falls back to no control characters if on unsupported terminal. * @param string Status message */ function status($msg) { + global $use_colors; $h = @fopen('php://stderr', 'w'); $label = ( defined('HTTPD_WS_CHILD') ) ? 'Child ' . substr(strval(getmypid()), -3) : 'Greyhound'; - fwrite($h, "\x1B[32;1m[$label] \x1B[32;0m$msg\x1B[0m\n"); + if ( $use_colors ) + { + fwrite($h, "\x1B[32;1m[$label] \x1B[32;0m$msg\x1B[0m\n"); + } + else + { + fwrite($h, "[$label] $msg\n"); + } fclose($h); } @@ -51,8 +67,16 @@ function warning($msg) { + global $use_colors; $h = @fopen('php://stderr', 'w'); - fwrite($h, "\x1B[33;1m[Greyhound] \x1B[0m\x1B[33mWarning:\x1B[0m $msg\n"); + if ( $use_colors ) + { + fwrite($h, "\x1B[33;1m[Greyhound] \x1B[0m\x1B[33mWarning:\x1B[0m $msg\n"); + } + else + { + fwrite($h, "[Greyhound] Warning: $msg\n"); + } fclose($h); }