1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

fixed logging after rebase

This commit is contained in:
Henning Koehler 2017-08-26 14:06:47 +12:00
parent 91fac7755a
commit c9ef773da0
5 changed files with 24 additions and 21 deletions

View File

@ -190,3 +190,4 @@ extern DLL_LINKAGE vstd::CLoggerBase * logBonus;
extern DLL_LINKAGE vstd::CLoggerBase * logNetwork; extern DLL_LINKAGE vstd::CLoggerBase * logNetwork;
extern DLL_LINKAGE vstd::CLoggerBase * logAi; extern DLL_LINKAGE vstd::CLoggerBase * logAi;
extern DLL_LINKAGE vstd::CLoggerBase * logAnim; extern DLL_LINKAGE vstd::CLoggerBase * logAnim;
extern DLL_LINKAGE vstd::CLoggerBase * logMod;

View File

@ -207,7 +207,7 @@ void CIdentifierStorage::registerObject(std::string scope, std::string type, std
std::pair<const std::string, ObjectData> mapping = std::make_pair(fullID, data); std::pair<const std::string, ObjectData> mapping = std::make_pair(fullID, data);
if(!vstd::containsMapping(registeredObjects, mapping)) if(!vstd::containsMapping(registeredObjects, mapping))
{ {
CLogger::getLogger(CLoggerDomain("identifier"))->traceStream() << "registered " << fullID << " as " << scope << ":" << identifier; logMod->trace("registered %s as %s:%s", fullID, scope, identifier);
registeredObjects.insert(mapping); registeredObjects.insert(mapping);
} }
} }
@ -377,7 +377,6 @@ bool CContentHandler::ContentTypeHandler::loadMod(std::string modName, bool vali
if (!modInfo.patches.isNull()) if (!modInfo.patches.isNull())
JsonUtils::merge(modInfo.modData, modInfo.patches); JsonUtils::merge(modInfo.modData, modInfo.patches);
CLogger * logger = CLogger::getLogger(CLoggerDomain("mod"));
for(auto & entry : modInfo.modData.Struct()) for(auto & entry : modInfo.modData.Struct())
{ {
const std::string & name = entry.first; const std::string & name = entry.first;
@ -390,7 +389,7 @@ bool CContentHandler::ContentTypeHandler::loadMod(std::string modName, bool vali
if (originalData.size() > index) if (originalData.size() > index)
{ {
logger->traceStream() << "found original data in loadMod(" << name << ") at index " << index; logMod->trace("found original data in loadMod(%s) at index %d", name, index);
JsonUtils::merge(originalData[index], data); JsonUtils::merge(originalData[index], data);
performValidate(originalData[index],name); performValidate(originalData[index],name);
handler->loadObject(modName, name, originalData[index], index); handler->loadObject(modName, name, originalData[index], index);
@ -398,14 +397,7 @@ bool CContentHandler::ContentTypeHandler::loadMod(std::string modName, bool vali
} }
else else
{ {
// trace only name field of original data - I miss list comprehension logMod->debug("no original data in loadMod(%s) at index %d", name, index);
std::vector<std::string> originalNames;
for (const JsonNode & orgElem : originalData)
originalNames.push_back(orgElem["name"].String());
logger->debugStream() << "no original data in loadMod(" << name << ") at index " << index;
logger->traceStream() << "originalData: " << originalNames;
logger->traceStream() << "new data: " << data;
performValidate(data, name); performValidate(data, name);
handler->loadObject(modName, name, data, index); handler->loadObject(modName, name, data, index);
} }

View File

@ -76,12 +76,25 @@ const std::string & CSkill::getDescription(int level) const
DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const CSkill::LevelInfo &info) DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const CSkill::LevelInfo &info)
{ {
return out << "(\"" << info.description << "\"," << info.effects << ")"; out << "(\"" << info.description << "\", [";
for(int i=0; i < info.effects.size(); i++)
out << (i ? "," : "") << info.effects[i]->Description();
return out << "])";
} }
DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const CSkill &skill) DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const CSkill &skill)
{ {
return out << "Skill(" << (int)skill.id << "," << skill.identifier << "): " << skill.levels; out << "Skill(" << (int)skill.id << "," << skill.identifier << "): [";
for(int i=0; i < skill.levels.size(); i++)
out << (i ? "," : "") << skill.levels[i];
return out << "]";
}
std::string CSkill::toString() const
{
std::ostringstream ss;
ss << *this;
return ss.str();
} }
///CSkillHandler ///CSkillHandler
@ -123,7 +136,7 @@ CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string &
if(!skill) if(!skill)
{ {
logGlobal->errorStream() << "unknown secondary skill " << identifier; logGlobal->error("unknown secondary skill %s", identifier);
throw std::runtime_error("invalid skill"); throw std::runtime_error("invalid skill");
} }
@ -143,9 +156,8 @@ CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string &
//CGI->generaltexth->skillInfoTexts[skill->id][level-1] = levelNode["description"].String(); //CGI->generaltexth->skillInfoTexts[skill->id][level-1] = levelNode["description"].String();
skill->setDescription(levelNode["description"].String(), level); skill->setDescription(levelNode["description"].String(), level);
} }
CLogger * logger = CLogger::getLogger(CLoggerDomain(getTypeName())); logMod->debug("loaded secondary skill %s(%d)", identifier, (int)skill->id);
logger->debugStream() << "loaded secondary skill " << identifier << "(" << (int)skill->id << ")"; logMod->trace("%s", skill->toString());
logger->traceStream() << *skill;
return skill; return skill;
} }
@ -180,10 +192,6 @@ void CSkillHandler::loadObject(std::string scope, std::string name, const JsonNo
void CSkillHandler::afterLoadFinalization() void CSkillHandler::afterLoadFinalization()
{ {
CLogger * logger = CLogger::getLogger(CLoggerDomain(getTypeName()));
logger->traceStream() << "skill handler after load: ";
for(auto skill : objects)
logger->traceStream() << *skill;
} }
void CSkillHandler::beforeValidate(JsonNode & object) void CSkillHandler::beforeValidate(JsonNode & object)

View File

@ -45,6 +45,7 @@ public:
void setDescription(const std::string & desc, int level); void setDescription(const std::string & desc, int level);
const std::vector<std::shared_ptr<Bonus>> & getBonus(int level) const; const std::vector<std::shared_ptr<Bonus>> & getBonus(int level) const;
const std::string & getDescription(int level) const; const std::string & getDescription(int level) const;
std::string toString() const;
SecondarySkill id; SecondarySkill id;
std::string identifier; std::string identifier;

View File

@ -83,6 +83,7 @@ DLL_LINKAGE vstd::CLoggerBase * logBonus = CLogger::getLogger(CLoggerDomain("bon
DLL_LINKAGE vstd::CLoggerBase * logNetwork = CLogger::getLogger(CLoggerDomain("network")); DLL_LINKAGE vstd::CLoggerBase * logNetwork = CLogger::getLogger(CLoggerDomain("network"));
DLL_LINKAGE vstd::CLoggerBase * logAi = CLogger::getLogger(CLoggerDomain("ai")); DLL_LINKAGE vstd::CLoggerBase * logAi = CLogger::getLogger(CLoggerDomain("ai"));
DLL_LINKAGE vstd::CLoggerBase * logAnim = CLogger::getLogger(CLoggerDomain("animation")); DLL_LINKAGE vstd::CLoggerBase * logAnim = CLogger::getLogger(CLoggerDomain("animation"));
DLL_LINKAGE vstd::CLoggerBase * logMod = CLogger::getLogger(CLoggerDomain("mod"));
CLogger * CLogger::getLogger(const CLoggerDomain & domain) CLogger * CLogger::getLogger(const CLoggerDomain & domain)
{ {