From 85e952f25fbe8c79350a03cd32a3822225d6e8db Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Thu, 10 Aug 2017 20:17:10 +0300 Subject: [PATCH] Logging cleanup 3 --- AI/VCAI/VCAI.cpp | 12 ++++++------ client/CMT.cpp | 2 +- client/Graphics.cpp | 2 +- client/widgets/CComponent.cpp | 3 +-- lib/mapObjects/CGTownInstance.cpp | 2 +- lib/mapObjects/CQuest.cpp | 2 +- lib/mapping/CMapEditManager.cpp | 4 ++-- lib/mapping/MapFormatH3M.cpp | 8 ++++---- lib/rmg/CMapGenOptions.cpp | 6 +++--- lib/rmg/CMapGenerator.cpp | 2 +- lib/rmg/CRmgTemplateStorage.cpp | 2 +- lib/rmg/CRmgTemplateZone.cpp | 6 +++--- lib/rmg/CZonePlacer.cpp | 2 +- 13 files changed, 26 insertions(+), 27 deletions(-) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index cb23d4daf..d7d276016 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -2348,7 +2348,7 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on } catch(std::exception &e) { - logAi->debugStream() << boost::format("Goal %s decomposition failed: %s") % goal->name() % e.what(); + logAi->debug("Goal %s decomposition failed: %s", goal->name(), e.what()); return sptr(Goals::Invalid()); } } @@ -2380,7 +2380,7 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on } else { - logAi->debugStream() << boost::format("Trying to realize %s (value %2.3f)") % goal->name() % goal->priority; + logAi->debug("Trying to realize %s (value %2.3f)", goal->name(), goal->priority); goal->accept(this); } @@ -2401,7 +2401,7 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on } catch(std::exception &e) { - logAi->debugStream() << boost::format("Failed to realize subgoal of type %s (greater goal type was %s), I will stop.") % goal->name() % ultimateGoal->name(); + logAi->debug("Failed to realize subgoal of type %s (greater goal type was %s), I will stop.", goal->name(), ultimateGoal->name()); logAi->debug("The error message was: %s", e.what()); break; } @@ -2553,7 +2553,7 @@ void VCAI::performTypicalActions() if(!h) //hero might be lost. getUnblockedHeroes() called once on start of turn continue; - logAi->debugStream() << boost::format("Looking into %s, MP=%d") % h->name.c_str() % h->movement; + logAi->debug("Looking into %s, MP=%d", h->name.c_str(), h->movement); makePossibleUpgrades(*h); pickBestArtifacts(*h); try @@ -2771,7 +2771,7 @@ void VCAI::checkHeroArmy (HeroPtr h) void VCAI::recruitHero(const CGTownInstance * t, bool throwing) { - logAi->debugStream() << boost::format("Trying to recruit a hero in %s at %s") % t->name % t->visitablePos(); + logAi->debug("Trying to recruit a hero in %s at %s", t->name, t->visitablePos()); auto heroes = cb->getAvailableHeroes(t); if(heroes.size()) @@ -2824,7 +2824,7 @@ void VCAI::lostHero(HeroPtr h) void VCAI::answerQuery(QueryID queryID, int selection) { - logAi->debugStream() << boost::format("I'll answer the query %d giving the choice %d") % queryID % selection; + logAi->debug("I'll answer the query %d giving the choice %d", queryID, selection); if(queryID != QueryID(-1)) { cb->selectionMade(selection, queryID); diff --git a/client/CMT.cpp b/client/CMT.cpp index dadd15cb9..b6eb06f42 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -906,7 +906,7 @@ void processCommand(const std::string &message) if(elem.second.human) { auto AiToGive = client->aiNameForPlayer(*client->getPlayerSettings(elem.first), false); - logNetwork->infoStream() << boost::format("Player %s will be lead by %s") % elem.first % AiToGive; + logNetwork->info("Player %s will be lead by %s", elem.first, AiToGive); client->installNewPlayerInterface(CDynLibHandler::getNewAI(AiToGive), elem.first); } } diff --git a/client/Graphics.cpp b/client/Graphics.cpp index 447ecff60..58d561737 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -364,7 +364,7 @@ std::shared_ptr Graphics::getAnimation(const ObjectTemplate & info) if(info.animationFile.empty()) { - logGlobal->warnStream() << boost::format("Def name for obj (%d,%d) is empty!") % info.id % info.subid; + logGlobal->warn("Def name for obj (%d,%d) is empty!", info.id, info.subid); return std::shared_ptr(); } diff --git a/client/widgets/CComponent.cpp b/client/widgets/CComponent.cpp index 27a2690b5..00cac6477 100644 --- a/client/widgets/CComponent.cpp +++ b/client/widgets/CComponent.cpp @@ -217,8 +217,7 @@ std::string CComponent::getSubtitleInternal() auto building = CGI->townh->factions[subtype]->town->buildings[BuildingID(val)]; if(!building) { - logGlobal->errorStream() << boost::format("Town of faction %s has no building #%d") - % CGI->townh->factions[subtype]->town->faction->name % val; + logGlobal->error("Town of faction %s has no building #%d", CGI->townh->factions[subtype]->town->faction->name, val); return (boost::format("Missing building #%d") % val).str(); } return building->Name(); diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 780793501..731b30918 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -1154,7 +1154,7 @@ void CGTownInstance::setVisitingHero(CGHeroInstance *h) { //if (!(!!visitingHero == !h)) //{ - // logGlobal->warnStream() << boost::format("Hero visiting town %s is %s ") % name % (visitingHero.get() ? visitingHero->name : "NULL"); + // logGlobal->warn("Hero visiting town %s is %s ", name, (visitingHero.get() ? visitingHero->name : "NULL")); // logGlobal->warn("New hero will be %s ", (h ? h->name : "NULL")); // //} diff --git a/lib/mapObjects/CQuest.cpp b/lib/mapObjects/CQuest.cpp index f0ccffb42..787929c8d 100644 --- a/lib/mapObjects/CQuest.cpp +++ b/lib/mapObjects/CQuest.cpp @@ -1049,7 +1049,7 @@ void CGKeys::setPropertyDer (ui8 what, ui32 val) //101-108 - enable key for play playerKeyMap[player].insert((ui8)val); } else - logGlobal->errorStream() << boost::format("Unexpected properties requested to set: what=%d, val=%d") % (int)what % val; + logGlobal->error("Unexpected properties requested to set: what=%d, val=%d", (int)what, val); } bool CGKeys::wasMyColorVisited (PlayerColor player) const diff --git a/lib/mapping/CMapEditManager.cpp b/lib/mapping/CMapEditManager.cpp index 2ccf2de84..fe0c77dff 100644 --- a/lib/mapping/CMapEditManager.cpp +++ b/lib/mapping/CMapEditManager.cpp @@ -575,14 +575,14 @@ void CDrawTerrainOperation::updateTerrainTypes() { const auto & centerPos = *(positions.begin()); auto centerTile = map->getTile(centerPos); - //logGlobal->debugStream() << boost::format("Set terrain tile at pos '%s' to type '%s'") % centerPos % centerTile.terType; + //logGlobal->debug("Set terrain tile at pos '%s' to type '%s'", centerPos, centerTile.terType); auto tiles = getInvalidTiles(centerPos); auto updateTerrainType = [&](const int3 & pos) { map->getTile(pos).terType = centerTile.terType; positions.insert(pos); invalidateTerrainViews(pos); - //logGlobal->debugStream() << boost::format("Set additional terrain tile at pos '%s' to type '%s'") % pos % centerTile.terType; + //logGlobal->debug("Set additional terrain tile at pos '%s' to type '%s'", pos, centerTile.terType); }; // Fill foreign invalid tiles diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index fe36bb3c9..a6d7e40a5 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/lib/mapping/MapFormatH3M.cpp @@ -810,7 +810,7 @@ void CMapLoaderH3M::loadArtifactsOfHero(CGHeroInstance * hero) { if(hero->artifactsWorn.size() || hero->artifactsInBackpack.size()) { - logGlobal->warnStream() << boost::format("Hero %s at %s has set artifacts twice (in map properties and on adventure map instance). Using the latter set...") % hero->name % hero->pos; + logGlobal->warn("Hero %s at %s has set artifacts twice (in map properties and on adventure map instance). Using the latter set...", hero->name, hero->pos); hero->artifactsInBackpack.clear(); while(hero->artifactsWorn.size()) hero->eraseArtSlot(hero->artifactsWorn.begin()->first); @@ -1622,7 +1622,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(ObjectInstanceID idToBeGiven, const i if(nhi->secSkills.size()) { nhi->secSkills.clear(); - //logGlobal->warnStream() << boost::format("Hero %s subID=%d has set secondary skills twice (in map properties and on adventure map instance). Using the latter set...") % nhi->name % nhi->subID; + //logGlobal->warn("Hero %s subID=%d has set secondary skills twice (in map properties and on adventure map instance). Using the latter set...", nhi->name, nhi->subID); } int howMany = reader.readUInt32(); @@ -1680,7 +1680,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(ObjectInstanceID idToBeGiven, const i if(nhi->spells.size()) { nhi->clear(); - logGlobal->warnStream() << boost::format("Hero %s subID=%d has spells set twice (in map properties and on adventure map instance). Using the latter set...") % nhi->name % nhi->subID; + logGlobal->warn("Hero %s subID=%d has spells set twice (in map properties and on adventure map instance). Using the latter set...", nhi->name, nhi->subID); } if(hasCustomSpells) @@ -1713,7 +1713,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(ObjectInstanceID idToBeGiven, const i .And(Selector::sourceType(Bonus::HERO_BASE_SKILL)), nullptr); if(ps->size()) { - logGlobal->warnStream() << boost::format("Hero %s subID=%d has set primary skills twice (in map properties and on adventure map instance). Using the latter set...") % nhi->name % nhi->subID; + logGlobal->warn("Hero %s subID=%d has set primary skills twice (in map properties and on adventure map instance). Using the latter set...", nhi->name, nhi->subID); for(auto b : *ps) nhi->removeBonus(b); } diff --git a/lib/rmg/CMapGenOptions.cpp b/lib/rmg/CMapGenOptions.cpp index 1c4de9376..4b1e3bfbf 100644 --- a/lib/rmg/CMapGenOptions.cpp +++ b/lib/rmg/CMapGenOptions.cpp @@ -292,10 +292,10 @@ void CMapGenOptions::finalize(CRandomGenerator & rand) default: assert(false); } - logGlobal->traceStream() << boost::format("Player %d: %s") % player.second.getColor() % playerType; + logGlobal->trace("Player %d: %s", player.second.getColor(), playerType); } setCompOnlyPlayerCount(cpuOnlyPlayers); //human players are set automaticlaly (?) - logGlobal->infoStream() << boost::format("Final player config: %d total, %d cpu-only") % players.size() % (int)getCompOnlyPlayerCount(); + logGlobal->info("Final player config: %d total, %d cpu-only", players.size(), (int)getCompOnlyPlayerCount()); } void CMapGenOptions::updatePlayers() @@ -340,7 +340,7 @@ void CMapGenOptions::updateCompOnlyPlayers() if (compOnlyPlayersToAdd < 0) { - logGlobal->errorStream() << boost::format("Incorrect number of players to add. Requested players %d, current players %d") % playerCount % players.size(); + logGlobal->error("Incorrect number of players to add. Requested players %d, current players %d", playerCount, players.size()); assert (compOnlyPlayersToAdd < 0); } for(int i = 0; i < compOnlyPlayersToAdd; ++i) diff --git a/lib/rmg/CMapGenerator.cpp b/lib/rmg/CMapGenerator.cpp index e4cf6d332..96bb68a7d 100644 --- a/lib/rmg/CMapGenerator.cpp +++ b/lib/rmg/CMapGenerator.cpp @@ -461,7 +461,7 @@ void CMapGenerator::createObstaclesCommon2() } } } - logGlobal->traceStream() << boost::format("Set %d tiles to BLOCKED and %d tiles to FREE") % blockedTiles % freeTiles; + logGlobal->trace("Set %d tiles to BLOCKED and %d tiles to FREE", blockedTiles, freeTiles); } } diff --git a/lib/rmg/CRmgTemplateStorage.cpp b/lib/rmg/CRmgTemplateStorage.cpp index 23f957265..c443d281a 100644 --- a/lib/rmg/CRmgTemplateStorage.cpp +++ b/lib/rmg/CRmgTemplateStorage.cpp @@ -228,7 +228,7 @@ void CRmgTemplateStorage::loadObject(std::string scope, std::string name, const } catch(const std::exception & e) { - logGlobal->errorStream() << boost::format("Template %s has errors. Message: %s.") % tpl->getName() % std::string(e.what()); + logGlobal->error("Template %s has errors. Message: %s.", tpl->getName(), std::string(e.what())); } } diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index af6d62ff1..1ff8a2648 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -839,7 +839,7 @@ bool CRmgTemplateZone::createRoad(CMapGenerator* gen, const int3& src, const int } } - logGlobal->warnStream() << boost::format("Failed to create road from %s to %s") % src %dst; + logGlobal->warn("Failed to create road from %s to %s", src, dst); return false; } @@ -1927,7 +1927,7 @@ bool CRmgTemplateZone::findPlaceForTreasurePile(CMapGenerator* gen, float min_di bool needsGuard = value > minGuardedValue; - //logGlobal->infoStream() << boost::format("Min dist for density %f is %d") % density % min_dist; + //logGlobal->info("Min dist for density %f is %d", density, min_dist); for(auto tile : possibleTiles) { auto dist = gen->getNearestObjectDistance(tile); @@ -2099,7 +2099,7 @@ void CRmgTemplateZone::checkAndPlaceObject(CMapGenerator* gen, CGObjectInstance* void CRmgTemplateZone::placeObject(CMapGenerator* gen, CGObjectInstance* object, const int3 &pos, bool updateDistance) { - //logGlobal->traceStream() << boost::format("Inserting object at %d %d") % pos.x % pos.y; + //logGlobal->trace("Inserting object at %d %d", pos.x, pos.y); checkAndPlaceObject (gen, object, pos); diff --git a/lib/rmg/CZonePlacer.cpp b/lib/rmg/CZonePlacer.cpp index 87f6dfadb..fd3cbe5c3 100644 --- a/lib/rmg/CZonePlacer.cpp +++ b/lib/rmg/CZonePlacer.cpp @@ -147,7 +147,7 @@ void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenera } } - logGlobal->traceStream() << boost::format("Best fitness reached: total distance %2.4f, total overlap %2.4f") % bestTotalDistance % bestTotalOverlap; + logGlobal->trace("Best fitness reached: total distance %2.4f, total overlap %2.4f", bestTotalDistance, bestTotalOverlap); for (auto zone : zones) //finalize zone positions { zone.second->setPos (cords (bestSolution[zone.second]));