mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
Merge branch 'release/3.3'
This commit is contained in:
commit
99fb267333
@ -87,7 +87,7 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function start() : void{
|
public function start() : void{
|
||||||
$this->rakLib->start(PTHREADS_INHERIT_CONSTANTS | PTHREADS_INHERIT_INI); //HACK: MainLogger needs INI and constants
|
$this->rakLib->start(PTHREADS_INHERIT_CONSTANTS); //HACK: MainLogger needs constants for exception logging
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setNetwork(Network $network) : void{
|
public function setNetwork(Network $network) : void{
|
||||||
|
@ -68,7 +68,7 @@ class RCONInstance extends Thread{
|
|||||||
$this->ipcSocket = $ipcSocket;
|
$this->ipcSocket = $ipcSocket;
|
||||||
$this->notifier = $notifier;
|
$this->notifier = $notifier;
|
||||||
|
|
||||||
$this->start(PTHREADS_INHERIT_INI); //HACK: need INI for timezone (logger)
|
$this->start(PTHREADS_INHERIT_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function writePacket($client, int $requestID, int $packetType, string $payload){
|
private function writePacket($client, int $requestID, int $packetType, string $payload){
|
||||||
|
@ -48,6 +48,9 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $mainThreadHasFormattingCodes = false;
|
private $mainThreadHasFormattingCodes = false;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private $timezone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $logFile
|
* @param string $logFile
|
||||||
* @param bool $logDebug
|
* @param bool $logDebug
|
||||||
@ -66,6 +69,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
|
|
||||||
//Child threads may not inherit command line arguments, so if there's an override it needs to be recorded here
|
//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->mainThreadHasFormattingCodes = Terminal::hasFormattingCodes();
|
||||||
|
$this->timezone = Timezone::get();
|
||||||
|
|
||||||
$this->start(PTHREADS_INHERIT_NONE);
|
$this->start(PTHREADS_INHERIT_NONE);
|
||||||
}
|
}
|
||||||
@ -253,7 +257,12 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function send($message, $level, $prefix, $color){
|
protected function send($message, $level, $prefix, $color){
|
||||||
$now = time();
|
/** @var \DateTime|null $time */
|
||||||
|
static $time = null;
|
||||||
|
if($time === null){ //thread-local
|
||||||
|
$time = new \DateTime('now', new \DateTimeZone($this->timezone));
|
||||||
|
}
|
||||||
|
$time->setTimestamp(time());
|
||||||
|
|
||||||
$thread = \Thread::getCurrentThread();
|
$thread = \Thread::getCurrentThread();
|
||||||
if($thread === null){
|
if($thread === null){
|
||||||
@ -264,9 +273,9 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
$threadName = (new \ReflectionClass($thread))->getShortName() . " thread";
|
$threadName = (new \ReflectionClass($thread))->getShortName() . " thread";
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = sprintf($this->format, date("H:i:s", $now), $color, $threadName, $prefix, $message);
|
$message = sprintf($this->format, $time->format("H:i:s"), $color, $threadName, $prefix, $message);
|
||||||
|
|
||||||
$this->synchronized(function() use ($message, $level, $now) : void{
|
$this->synchronized(function() use ($message, $level, $time) : void{
|
||||||
$cleanMessage = TextFormat::clean($message);
|
$cleanMessage = TextFormat::clean($message);
|
||||||
|
|
||||||
if($this->mainThreadHasFormattingCodes and Terminal::hasFormattingCodes()){ //hasFormattingCodes() lazy-inits colour codes because we don't know if they've been registered on this thread
|
if($this->mainThreadHasFormattingCodes and Terminal::hasFormattingCodes()){ //hasFormattingCodes() lazy-inits colour codes because we don't know if they've been registered on this thread
|
||||||
@ -279,7 +288,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
$attachment->call($level, $message);
|
$attachment->call($level, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logStream[] = date("Y-m-d", $now) . " " . $cleanMessage . PHP_EOL;
|
$this->logStream[] = $time->format("Y-m-d") . " " . $cleanMessage . PHP_EOL;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user