mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 22:45:28 +00:00
MainLogger: workaround --disable-ansi not being respected on other threads
This commit is contained in:
parent
3725bea3e5
commit
9657d50aeb
@ -45,6 +45,9 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
private $format = TextFormat::AQUA . "[%s] " . TextFormat::RESET . "%s[%s/%s]: %s" . TextFormat::RESET;
|
private $format = TextFormat::AQUA . "[%s] " . TextFormat::RESET . "%s[%s/%s]: %s" . TextFormat::RESET;
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $mainThreadHasFormattingCodes = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $logFile
|
* @param string $logFile
|
||||||
* @param bool $logDebug
|
* @param bool $logDebug
|
||||||
@ -60,6 +63,10 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
$this->logFile = $logFile;
|
$this->logFile = $logFile;
|
||||||
$this->logDebug = $logDebug;
|
$this->logDebug = $logDebug;
|
||||||
$this->logStream = new \Threaded;
|
$this->logStream = new \Threaded;
|
||||||
|
|
||||||
|
//Child threads may not inherit command line arguments, so if there's an override it needs to be recorded here
|
||||||
|
$this->mainThreadHasFormattingCodes = Terminal::hasFormattingCodes();
|
||||||
|
|
||||||
$this->start(PTHREADS_INHERIT_NONE);
|
$this->start(PTHREADS_INHERIT_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +235,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
$message = sprintf($this->format, date("H:i:s", $now), $color, $threadName, $prefix, $message);
|
$message = sprintf($this->format, date("H:i:s", $now), $color, $threadName, $prefix, $message);
|
||||||
$cleanMessage = TextFormat::clean($message);
|
$cleanMessage = TextFormat::clean($message);
|
||||||
|
|
||||||
if(Terminal::hasFormattingCodes()){
|
if($this->mainThreadHasFormattingCodes and Terminal::hasFormattingCodes()){ //hasFormattingCodes() lazy-inits colour codes because we don't know if they've been registered on this thread
|
||||||
echo Terminal::toANSI($message) . PHP_EOL;
|
echo Terminal::toANSI($message) . PHP_EOL;
|
||||||
}else{
|
}else{
|
||||||
echo $cleanMessage . PHP_EOL;
|
echo $cleanMessage . PHP_EOL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user