2017-01-09 01:24:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class LogFuncs {
|
|
|
|
public static function bind() {
|
|
|
|
static $bound;
|
|
|
|
if ($bound++) return;
|
|
|
|
}
|
|
|
|
}
|
2017-01-10 14:13:49 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-02-12 01:32:17 +00:00
|
|
|
function log_info($fmt,...$arg) { defined("QUIET") || printf(LF_INFO."[info] {$fmt}".LF_RESET."\n", ...$arg); }
|
|
|
|
function log_debug($fmt,...$arg) { defined("QUIET") || printf(LF_DEBUG."[debg] {$fmt}".LF_RESET."\n", ...$arg); }
|
|
|
|
function log_warn($fmt,...$arg) { defined("QUIET") || printf(LF_WARN."[warn] {$fmt}".LF_RESET."\n", ...$arg); }
|