protected function send($message, $level, $prefix, $color)
{
$now = time();
$thread = \Thread::getCurrentThread();
if ($thread === null) {
$threadName = "Server thread";
} elseif ($thread instanceof Thread or $thread instanceof Worker) {
$threadName = $thread->getThreadName() . " thread";
} else {
$threadName = (new \ReflectionClass($thread))->getShortName() . " thread";
}
$message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s", $now) . "] " . TextFormat::RESET . $color . "[" . $prefix . "]:" . " " . $message . TextFormat::RESET);
//$message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s") . "] ". TextFormat::RESET . $color ."<".$prefix . ">" . " " . $message . TextFormat::RESET);
$cleanMessage = TextFormat::clean($message);
if (!Terminal::hasFormattingCodes()) {
echo $cleanMessage . PHP_EOL;
} else {
echo $message . PHP_EOL;
}
if ($this->attachment instanceof \ThreadedLoggerAttachment) {
$this->attachment->call($level, $message);
}
$this->logStream[] = date("Y-m-d", $now) . " " . $cleanMessage . "\n";
if ($this->logStream->count() === 1) {
$this->synchronized(function () {
$this->notify();
});
}
}