mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-22 08:05:34 +08:00
62 lines
2.0 KiB
PHP
62 lines
2.0 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* Created by PhpStorm.
|
||
|
|
* User: jerry
|
||
|
|
* Date: 2018/3/29
|
||
|
|
* Time: 11:32
|
||
|
|
*/
|
||
|
|
|
||
|
|
class Console
|
||
|
|
{
|
||
|
|
static function setColor($string, $color = ""){
|
||
|
|
switch ($color) {
|
||
|
|
case "red":
|
||
|
|
return "\x1b[38;5;203m" . $string . "\x1b[m";
|
||
|
|
case "green":
|
||
|
|
return "\x1b[38;5;83m" . $string . "\x1b[m";
|
||
|
|
case "yellow":
|
||
|
|
return "\x1b[38;5;227m" . $string . "\x1b[m";
|
||
|
|
case "blue":
|
||
|
|
return "\033[34m" . $string . "\033[0m";
|
||
|
|
case "lightpurple":
|
||
|
|
return "\x1b[38;5;207m" . $string . "\x1b[m";
|
||
|
|
case "lightblue":
|
||
|
|
return "\x1b[38;5;87m" . $string . "\x1b[m";
|
||
|
|
case "gold":
|
||
|
|
return "\x1b[38;5;214m" . $string . "\x1b[m";
|
||
|
|
case "gray":
|
||
|
|
return "\x1b[38;5;59m" . $string . "\x1b[m";
|
||
|
|
case "pink":
|
||
|
|
return "\x1b[38;5;207m" . $string . "\x1b[m";
|
||
|
|
case "lightlightblue":
|
||
|
|
return "\x1b[38;5;63m" . $string . "\x1b[m";
|
||
|
|
default:
|
||
|
|
return $string;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
static function debug($obj, $head = null){
|
||
|
|
if ($head === null) $head = "[DEBUG] " . date("H:i:s") . " ";
|
||
|
|
if (Buffer::get("info_level") < 2) return;
|
||
|
|
if (!is_string($obj)) var_dump($obj);
|
||
|
|
else echo(self::setColor($head . $obj, "green") . "\n");
|
||
|
|
}
|
||
|
|
|
||
|
|
static function error($obj, $head = null){
|
||
|
|
if ($head === null) $head = "[ERROR] " . date("H:i:s") . " ";
|
||
|
|
if (!is_string($obj)) var_dump($obj);
|
||
|
|
else echo(self::setColor($head . $obj, "red") . "\n");
|
||
|
|
}
|
||
|
|
|
||
|
|
static function info($obj, $head = null){
|
||
|
|
if ($head === null) $head = "[INFO] " . date("H:i:s") . " ";
|
||
|
|
if (!is_string($obj)) var_dump($obj);
|
||
|
|
else echo(self::setColor($head . $obj, "blue") . "\n");
|
||
|
|
}
|
||
|
|
|
||
|
|
static function put($obj, $color = ""){
|
||
|
|
if (!is_string($obj)) var_dump($obj);
|
||
|
|
else echo(self::setColor($obj, $color) . "\n");
|
||
|
|
}
|
||
|
|
}
|