MainLogger: Colorize at point of echo, not beforehand

this removes the need for a hack I had to do with ClientConsole to translate ANSI colour codes back into MC colour codes.
This commit is contained in:
Dylan K. Taylor 2018-05-09 18:04:16 +01:00
parent 5c66c615bf
commit b96adda14d

View File

@ -214,13 +214,13 @@ class MainLogger extends \AttachableThreadedLogger{
$threadName = (new \ReflectionClass($thread))->getShortName() . " thread";
}
$message = Terminal::toANSI(TextFormat::AQUA . "[" . date("H:i:s", $now) . "] " . TextFormat::RESET . $color . "[" . $threadName . "/" . $prefix . "]:" . " " . $message . TextFormat::RESET);
$message = TextFormat::AQUA . "[" . date("H:i:s", $now) . "] " . TextFormat::RESET . $color . "[" . $threadName . "/" . $prefix . "]:" . " " . $message . TextFormat::RESET;
$cleanMessage = TextFormat::clean($message);
if(!Terminal::hasFormattingCodes()){
echo $cleanMessage . PHP_EOL;
if(Terminal::hasFormattingCodes()){
echo Terminal::toANSI($message) . PHP_EOL;
}else{
echo $message . PHP_EOL;
echo $cleanMessage . PHP_EOL;
}
foreach($this->attachments as $attachment){