mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-20 18:31:23 +00:00
MainLogger: Use millisecond precision on log timestamps
This commit is contained in:
parent
3175a319a2
commit
714393820f
@ -33,7 +33,6 @@ use function get_class;
|
||||
use function is_resource;
|
||||
use function preg_replace;
|
||||
use function sprintf;
|
||||
use function time;
|
||||
use function touch;
|
||||
use function trim;
|
||||
use const PHP_EOL;
|
||||
@ -250,12 +249,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
}
|
||||
|
||||
protected function send($message, $level, $prefix, $color) : void{
|
||||
/** @var \DateTime|null $time */
|
||||
static $time = null;
|
||||
if($time === null){ //thread-local
|
||||
$time = new \DateTime('now', new \DateTimeZone($this->timezone));
|
||||
}
|
||||
$time->setTimestamp(time());
|
||||
$time = new \DateTime('now', new \DateTimeZone($this->timezone));
|
||||
|
||||
$thread = \Thread::getCurrentThread();
|
||||
if($thread === null){
|
||||
@ -266,7 +260,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
$threadName = (new \ReflectionClass($thread))->getShortName() . " thread";
|
||||
}
|
||||
|
||||
$message = sprintf($this->format, $time->format("H:i:s"), $color, $threadName, $prefix, $message);
|
||||
$message = sprintf($this->format, $time->format("H:i:s.v"), $color, $threadName, $prefix, $message);
|
||||
|
||||
if(!Terminal::isInit()){
|
||||
Terminal::init($this->mainThreadHasFormattingCodes); //lazy-init colour codes because we don't know if they've been registered on this thread
|
||||
|
Loading…
x
Reference in New Issue
Block a user