From 593efe2b3b01224c64a2390df5d6c3f4892dd743 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 7 Jul 2017 23:31:42 +0100 Subject: [PATCH] Check if is a tty --- src/danog/MadelineProto/Logger.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/danog/MadelineProto/Logger.php b/src/danog/MadelineProto/Logger.php index beb78bb6..beefe2ea 100644 --- a/src/danog/MadelineProto/Logger.php +++ b/src/danog/MadelineProto/Logger.php @@ -90,6 +90,7 @@ class Logger public static $BIG_ENDIAN = false; public static $bigint = true; public static $colors = []; + public static $isatty = false; const ULTRA_VERBOSE = 5; const VERBOSE = 4; @@ -112,6 +113,7 @@ class Logger self::$colors[self::WARNING] = implode(';', [self::foreground['white'], self::set['dim'], self::background['red']]); self::$colors[self::ERROR] = implode(';', [self::foreground['white'], self::set['bold'], self::background['red']]); self::$colors[self::FATAL_ERROR] = implode(';', [self::foreground['red'], self::set['bold'], self::background['light_gray']]); + self::$isatty = posix_isatty(STDOUT); } /* @@ -163,7 +165,7 @@ class Logger error_log($param.PHP_EOL, 3, self::$optional); break; case 3: - echo "\033[".self::$colors[$level].'m'.$param."\033[0m".PHP_EOL; + echo self::$isatty ? "\033[".self::$colors[$level].'m'.$param."\033[0m".PHP_EOL : $param.PHP_EOL; break; default: break;