improve WorldServer debug logging

is now consistent with WorldServerThread's use of the world id, which is generally more appropriate
This commit is contained in:
Kae 2023-07-03 19:32:23 +10:00
parent 0d266bebe1
commit f73cb3ce03
4 changed files with 26 additions and 9 deletions

View File

@ -52,7 +52,7 @@ void SystemWorldServerThread::run() {
TickRateApproacher tickApproacher(1.0 / SystemWorldTimestep, 0.5);
while (!m_stop) {
LogMap::set(strf("system_{}_update_fps", m_systemLocation), tickApproacher.rate());
LogMap::set(strf("system_{}_update_rate", m_systemLocation), strf("{:4.2f}Hz", tickApproacher.rate()));
update();

View File

@ -40,6 +40,7 @@ WorldServer::WorldServer(WorldTemplatePtr const& worldTemplate, IODevicePtr stor
m_respawnInWorld = false;
m_tileProtectionEnabled = true;
m_universeSettings = make_shared<UniverseSettings>();
m_worldId = worldTemplate->worldName();
init(true);
writeMetadata();
@ -52,6 +53,7 @@ WorldServer::WorldServer(IODevicePtr const& storage) {
m_worldStorage = make_shared<WorldStorage>(storage, make_shared<WorldGenerator>(this));
m_tileProtectionEnabled = true;
m_universeSettings = make_shared<UniverseSettings>();
m_worldId = "Nowhere";
readMetadata();
init(false);
@ -61,6 +63,7 @@ WorldServer::WorldServer(WorldChunks const& chunks) {
m_worldStorage = make_shared<WorldStorage>(chunks, make_shared<WorldGenerator>(this));
m_tileProtectionEnabled = true;
m_universeSettings = make_shared<UniverseSettings>();
m_worldId = "Nowhere";
readMetadata();
init(false);
@ -72,6 +75,14 @@ WorldServer::~WorldServer() {
m_worldStorage->unloadAll(true);
}
void WorldServer::setWorldId(String worldId) {
m_worldId = move(worldId);
}
String const& WorldServer::worldId() const {
return m_worldId;
}
void WorldServer::setUniverseSettings(UniverseSettingsPtr universeSettings) {
m_universeSettings = move(universeSettings);
}
@ -616,12 +627,10 @@ void WorldServer::update() {
for (auto& pair : m_clientInfo)
pair.second->pendingForward = false;
LogMap::set(strf("server_{}_entities", m_worldTemplate->worldSeed()), m_entityMap->size());
LogMap::set(strf("server_{}_sectors", m_worldTemplate->worldSeed()), strf("{}", m_tileArray->loadedSectorCount()));
LogMap::set(strf("server_{}_world_time", m_worldTemplate->worldSeed()), epochTime());
LogMap::set(strf("server_{}_active_liquid", m_worldTemplate->worldSeed()), m_liquidEngine->activeCells());
LogMap::set(strf("server_{}_day_time", m_worldTemplate->worldSeed()), timeOfDay() / dayLength());
LogMap::set(strf("server_{}_lua_mem", m_worldTemplate->worldSeed()), m_luaRoot->luaMemoryUsage());
LogMap::set(strf("server_{}_entities", m_worldId), strf("{} in {} sectors", m_entityMap->size(), m_tileArray->loadedSectorCount()));
LogMap::set(strf("server_{}_time", m_worldId), strf("age = {:4.2f}, day = {:4.2f}/{:4.2f}s", epochTime(), timeOfDay(), dayLength()));
LogMap::set(strf("server_{}_active_liquid", m_worldId), m_liquidEngine->activeCells());
LogMap::set(strf("server_{}_lua_mem", m_worldId), m_luaRoot->luaMemoryUsage());
}
WorldGeometry WorldServer::geometry() const {

View File

@ -57,6 +57,9 @@ public:
// Load an existing world from an in-memory representation
~WorldServer();
void setWorldId(String worldId);
String const& worldId() const;
void setUniverseSettings(UniverseSettingsPtr universeSettings);
UniverseSettingsPtr universeSettings() const;
@ -374,6 +377,8 @@ private:
HashMap<Uuid, pair<ConnectionId, MVariant<ConnectionId, RpcPromiseKeeper<Json>>>> m_entityMessageResponses;
List<PhysicsForceRegion> m_forceRegions;
String m_worldId;
};
}

View File

@ -13,7 +13,10 @@ WorldServerThread::WorldServerThread(WorldServerPtr server, WorldId worldId)
m_worldServer(move(server)),
m_worldId(move(worldId)),
m_stop(false),
m_errorOccurred(false) {}
m_errorOccurred(false) {
if (m_worldServer)
m_worldServer->setWorldId(printWorldId(m_worldId));
}
WorldServerThread::~WorldServerThread() {
m_stop = true;
@ -195,7 +198,7 @@ void WorldServerThread::run() {
while (!m_stop && !m_errorOccurred) {
auto fidelity = lockedFidelity.value(automaticFidelity);
LogMap::set(strf("server_{}_fidelity", m_worldId), WorldServerFidelityNames.getRight(fidelity));
LogMap::set(strf("server_{}_update_fps", m_worldId), tickApproacher.rate());
LogMap::set(strf("server_{}_update", m_worldId), strf("{:4.2f}Hz", tickApproacher.rate()));
update(fidelity);
tickApproacher.tick();