Colored output for TTYs, props added
This commit is contained in:
@ -6,6 +6,21 @@ class LogFuncs {
|
||||
if ($bound++) return;
|
||||
}
|
||||
}
|
||||
function log_info($fmt,...$arg) { printf("[info] {$fmt}\n", ...$arg); }
|
||||
function log_debug($fmt,...$arg) { printf("[debg] {$fmt}\n", ...$arg); }
|
||||
function log_warn($fmt,...$arg) { printf("[warn] {$fmt}\n", ...$arg); }
|
||||
|
||||
if (@empty(STDOUT) || (!posix_isatty(STDOUT))) {
|
||||
define("LF_INFO", "");
|
||||
define("LF_DEBUG", "");
|
||||
define("LF_WARN", "");
|
||||
define("LF_RESET", "");
|
||||
define("IS_TTY", false);
|
||||
} else {
|
||||
define("LF_INFO", "\e[32;1m");
|
||||
define("LF_DEBUG", "\e[32m");
|
||||
define("LF_WARN", "\e[31;1m");
|
||||
define("LF_RESET", "\e[0m");
|
||||
define("IS_TTY", true);
|
||||
}
|
||||
|
||||
function log_info($fmt,...$arg) { printf(LF_INFO."[info] {$fmt}".LF_RESET."\n", ...$arg); }
|
||||
function log_debug($fmt,...$arg) { printf(LF_DEBUG."[debg] {$fmt}".LF_RESET."\n", ...$arg); }
|
||||
function log_warn($fmt,...$arg) { printf(LF_WARN."[warn] {$fmt}".LF_RESET."\n", ...$arg); }
|
Reference in New Issue
Block a user