17 function __construct($name=
"root", $pDevMode=
false) {
20 $this->devMode = $pDevMode;
23 abstract protected function log($level, $log);
37 if (count($args) == 1) {
38 $logMsg = array_shift($args);
45 $fmt = array_shift($args);
46 $logMsg = vsprintf($fmt, $args);
49 return $this->log($level, $logMsg);
66 function info(...$msg) {
70 function warning(...$msg) {
72 return $this->notice(...$msg);
75 function notice(...$msg) {
78 function error(...$msg) {
86 protected function log($level, $msg) {
87 $log = sprintf(
"[%s] [%s]: %s\n", $level, $this->name, $msg);
88 return fwrite($this->fd, $log);
91 function __construct(...$args) {
92 $this->fd = fopen(
'php://stdout',
'w');
93 parent::__construct(...$args);
100 protected $level_to_color = [
107 protected $color_to_vt100 = [
109 'yellow' =>
"\033[30;43m",
110 'blue' =>
"\033[34;47m",
111 'green' =>
"\33[32m",
112 'purple' =>
"\033[35m",
113 'red' =>
"\033[37;41m" 116 protected function log($level, $msg) {
118 $color = $this->level_to_color[$level];
119 $vt100 = $this->color_to_vt100[$color];
120 $level = $vt100 . $level .
"\033[0m";
121 return parent::log($level, $msg);
130 function getLogger($name, $pDevMode=
false) {
131 $testfd = fopen(
'php://stdout',
'w');
133 if (posix_isatty($testfd)) {
log_format($level,... $args)