mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 01:51:51 +00:00
MainLogger: accept main thread name as a constructor parameter
This commit is contained in:
parent
709b4154d7
commit
27b1951df7
@ -237,7 +237,7 @@ namespace pocketmine {
|
|||||||
Terminal::init();
|
Terminal::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
$logger = new MainLogger($dataPath . "server.log", Terminal::hasFormattingCodes());
|
$logger = new MainLogger($dataPath . "server.log", Terminal::hasFormattingCodes(), "Server");
|
||||||
\GlobalLogger::set($logger);
|
\GlobalLogger::set($logger);
|
||||||
|
|
||||||
emit_performance_warnings($logger);
|
emit_performance_warnings($logger);
|
||||||
|
@ -44,6 +44,8 @@ class MainLogger extends \AttachableThreadedLogger implements \BufferedLogger{
|
|||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $useFormattingCodes = false;
|
private $useFormattingCodes = false;
|
||||||
|
|
||||||
|
private string $mainThreadName;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $timezone;
|
private $timezone;
|
||||||
|
|
||||||
@ -53,11 +55,12 @@ class MainLogger extends \AttachableThreadedLogger implements \BufferedLogger{
|
|||||||
/**
|
/**
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function __construct(string $logFile, bool $useFormattingCodes, bool $logDebug = false){
|
public function __construct(string $logFile, bool $useFormattingCodes, string $mainThreadName, bool $logDebug = false){
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->logDebug = $logDebug;
|
$this->logDebug = $logDebug;
|
||||||
|
|
||||||
$this->useFormattingCodes = $useFormattingCodes;
|
$this->useFormattingCodes = $useFormattingCodes;
|
||||||
|
$this->mainThreadName = $mainThreadName;
|
||||||
$this->timezone = Timezone::get();
|
$this->timezone = Timezone::get();
|
||||||
|
|
||||||
$this->logWriterThread = new MainLoggerThread($logFile);
|
$this->logWriterThread = new MainLoggerThread($logFile);
|
||||||
@ -223,7 +226,7 @@ class MainLogger extends \AttachableThreadedLogger implements \BufferedLogger{
|
|||||||
|
|
||||||
$thread = \Thread::getCurrentThread();
|
$thread = \Thread::getCurrentThread();
|
||||||
if($thread === null){
|
if($thread === null){
|
||||||
$threadName = "Server thread";
|
$threadName = $this->mainThreadName . " thread";
|
||||||
}elseif($thread instanceof Thread or $thread instanceof Worker){
|
}elseif($thread instanceof Thread or $thread instanceof Worker){
|
||||||
$threadName = $thread->getThreadName() . " thread";
|
$threadName = $thread->getThreadName() . " thread";
|
||||||
}else{
|
}else{
|
||||||
|
@ -43,7 +43,7 @@ class AsyncPoolTest extends TestCase{
|
|||||||
|
|
||||||
public function setUp() : void{
|
public function setUp() : void{
|
||||||
@define('pocketmine\\COMPOSER_AUTOLOADER_PATH', dirname(__DIR__, 3) . '/vendor/autoload.php');
|
@define('pocketmine\\COMPOSER_AUTOLOADER_PATH', dirname(__DIR__, 3) . '/vendor/autoload.php');
|
||||||
$this->mainLogger = new MainLogger(tempnam(sys_get_temp_dir(), "pmlog"), false);
|
$this->mainLogger = new MainLogger(tempnam(sys_get_temp_dir(), "pmlog"), false, "Main");
|
||||||
$this->pool = new AsyncPool(2, 1024, new \BaseClassLoader(), $this->mainLogger, new SleeperHandler());
|
$this->pool = new AsyncPool(2, 1024, new \BaseClassLoader(), $this->mainLogger, new SleeperHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user