mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
World: add and use a prefixed logger in some places
This commit is contained in:
parent
3c3e5a9850
commit
89d4f596bd
@ -99,7 +99,7 @@ class ChunkCache implements ChunkListener{
|
|||||||
$this->world->getChunk($chunkX, $chunkZ),
|
$this->world->getChunk($chunkX, $chunkZ),
|
||||||
$this->caches[$chunkHash],
|
$this->caches[$chunkHash],
|
||||||
function() use($chunkX, $chunkZ){
|
function() use($chunkX, $chunkZ){
|
||||||
$this->world->getServer()->getLogger()->error("Failed preparing chunk for " . $this->world->getDisplayName() . " chunk $chunkX $chunkZ, retrying");
|
$this->world->getLogger()->error("Failed preparing chunk $chunkX $chunkZ, retrying");
|
||||||
|
|
||||||
$this->restartPendingRequest($chunkX, $chunkZ);
|
$this->restartPendingRequest($chunkX, $chunkZ);
|
||||||
}
|
}
|
||||||
|
@ -266,6 +266,9 @@ class World implements ChunkManager, Metadatable{
|
|||||||
/** @var SkyLightUpdate|null */
|
/** @var SkyLightUpdate|null */
|
||||||
private $skyLightUpdate = null;
|
private $skyLightUpdate = null;
|
||||||
|
|
||||||
|
/** @var \Logger */
|
||||||
|
private $logger;
|
||||||
|
|
||||||
public static function chunkHash(int $x, int $z) : int{
|
public static function chunkHash(int $x, int $z) : int{
|
||||||
return (($x & 0xFFFFFFFF) << 32) | ($z & 0xFFFFFFFF);
|
return (($x & 0xFFFFFFFF) << 32) | ($z & 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
@ -352,6 +355,8 @@ class World implements ChunkManager, Metadatable{
|
|||||||
$this->provider = $provider;
|
$this->provider = $provider;
|
||||||
|
|
||||||
$this->displayName = $this->provider->getWorldData()->getName();
|
$this->displayName = $this->provider->getWorldData()->getName();
|
||||||
|
$this->logger = new \PrefixedLogger($server->getLogger(), "World: $this->displayName");
|
||||||
|
|
||||||
$this->worldHeight = $this->provider->getWorldHeight();
|
$this->worldHeight = $this->provider->getWorldHeight();
|
||||||
|
|
||||||
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.level.preparing", [$this->displayName]));
|
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.level.preparing", [$this->displayName]));
|
||||||
@ -419,6 +424,10 @@ class World implements ChunkManager, Metadatable{
|
|||||||
return $this->server;
|
return $this->server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLogger() : \Logger{
|
||||||
|
return $this->logger;
|
||||||
|
}
|
||||||
|
|
||||||
final public function getProvider() : WritableWorldProvider{
|
final public function getProvider() : WritableWorldProvider{
|
||||||
return $this->provider;
|
return $this->provider;
|
||||||
}
|
}
|
||||||
@ -2526,8 +2535,7 @@ class World implements ChunkManager, Metadatable{
|
|||||||
try{
|
try{
|
||||||
$chunk = $this->provider->loadChunk($x, $z);
|
$chunk = $this->provider->loadChunk($x, $z);
|
||||||
}catch(CorruptedChunkException | UnsupportedChunkFormatException $e){
|
}catch(CorruptedChunkException | UnsupportedChunkFormatException $e){
|
||||||
$logger = $this->server->getLogger();
|
$this->logger->critical("Failed to load chunk x=$x z=$z: " . $e->getMessage());
|
||||||
$logger->critical("Failed to load chunk x=$x z=$z: " . $e->getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($chunk === null and $create){
|
if($chunk === null and $create){
|
||||||
@ -2553,7 +2561,7 @@ class World implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->isChunkInUse($x, $z)){
|
if(!$this->isChunkInUse($x, $z)){
|
||||||
$this->server->getLogger()->debug("Newly loaded chunk $x $z has no loaders registered, will be unloaded at next available opportunity");
|
$this->logger->debug("Newly loaded chunk $x $z has no loaders registered, will be unloaded at next available opportunity");
|
||||||
$this->unloadChunkRequest($x, $z);
|
$this->unloadChunkRequest($x, $z);
|
||||||
}
|
}
|
||||||
foreach($this->getChunkListeners($x, $z) as $listener){
|
foreach($this->getChunkListeners($x, $z) as $listener){
|
||||||
|
@ -587,12 +587,12 @@ class Chunk{
|
|||||||
try{
|
try{
|
||||||
$entity = EntityFactory::createFromData($world, $nbt);
|
$entity = EntityFactory::createFromData($world, $nbt);
|
||||||
if(!($entity instanceof Entity)){
|
if(!($entity instanceof Entity)){
|
||||||
$world->getServer()->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown entity type " . $nbt->getString("id", $nbt->getString("identifier", "<unknown>", true), true));
|
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown entity type " . $nbt->getString("id", $nbt->getString("identifier", "<unknown>", true), true));
|
||||||
$changed = true;
|
$changed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}catch(\Exception $t){ //TODO: this shouldn't be here
|
}catch(\Exception $t){ //TODO: this shouldn't be here
|
||||||
$world->getServer()->getLogger()->logException($t);
|
$world->getLogger()->logException($t);
|
||||||
$changed = true;
|
$changed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -606,7 +606,7 @@ class Chunk{
|
|||||||
if(($tile = TileFactory::createFromData($world, $nbt)) !== null){
|
if(($tile = TileFactory::createFromData($world, $nbt)) !== null){
|
||||||
$world->addTile($tile);
|
$world->addTile($tile);
|
||||||
}else{
|
}else{
|
||||||
$world->getServer()->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>", true));
|
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>", true));
|
||||||
$changed = true;
|
$changed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user