Simplify error logging

This commit is contained in:
Akkadius
2019-09-01 22:05:44 -05:00
parent 98cbb7d781
commit 678c25e02c
44 changed files with 532 additions and 486 deletions
+16 -12
View File
@@ -103,7 +103,7 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo
auto results = database.QueryDatabase(query);
if(!results.Success()) {
Log(Logs::General, Logs::Error, "Error inserting into raid members: %s", results.ErrorMessage().c_str());
LogError("Error inserting into raid members: [{}]", results.ErrorMessage().c_str());
}
LearnMembers();
@@ -266,12 +266,12 @@ void Raid::SetRaidLeader(const char *wasLead, const char *name)
std::string query = StringFormat("UPDATE raid_members SET israidleader = 0 WHERE name = '%s'", wasLead);
auto results = database.QueryDatabase(query);
if (!results.Success())
Log(Logs::General, Logs::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str());
LogError("Set Raid Leader error: [{}]\n", results.ErrorMessage().c_str());
query = StringFormat("UPDATE raid_members SET israidleader = 1 WHERE name = '%s'", name);
results = database.QueryDatabase(query);
if (!results.Success())
Log(Logs::General, Logs::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str());
LogError("Set Raid Leader error: [{}]\n", results.ErrorMessage().c_str());
strn0cpy(leadername, name, 64);
@@ -304,7 +304,7 @@ void Raid::SaveGroupLeaderAA(uint32 gid)
safe_delete_array(queryBuffer);
auto results = database.QueryDatabase(query);
if (!results.Success())
Log(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str());
LogError("Unable to store LeadershipAA: [{}]\n", results.ErrorMessage().c_str());
}
void Raid::SaveRaidLeaderAA()
@@ -318,7 +318,7 @@ void Raid::SaveRaidLeaderAA()
safe_delete_array(queryBuffer);
auto results = database.QueryDatabase(query);
if (!results.Success())
Log(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str());
LogError("Unable to store LeadershipAA: [{}]\n", results.ErrorMessage().c_str());
}
void Raid::UpdateGroupAAs(uint32 gid)
@@ -1455,10 +1455,14 @@ void Raid::GetRaidDetails()
if (!results.Success())
return;
if (results.RowCount() == 0) {
Log(Logs::General, Logs::Error, "Error getting raid details for raid %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str());
return;
}
if (results.RowCount() == 0) {
LogError(
"Error getting raid details for raid [{}]: [{}]",
(unsigned long) GetID(),
results.ErrorMessage().c_str()
);
return;
}
auto row = results.begin();
@@ -1488,7 +1492,7 @@ bool Raid::LearnMembers()
return false;
if(results.RowCount() == 0) {
Log(Logs::General, Logs::Error, "Error getting raid members for raid %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str());
LogError("Error getting raid members for raid [{}]: [{}]", (unsigned long)GetID(), results.ErrorMessage().c_str());
disbandCheck = true;
return false;
}
@@ -1750,7 +1754,7 @@ void Raid::SetGroupMentor(uint32 group_id, int percent, char *name)
name, percent, group_id, GetID());
auto results = database.QueryDatabase(query);
if (!results.Success())
Log(Logs::General, Logs::Error, "Unable to set raid group mentor: %s\n", results.ErrorMessage().c_str());
LogError("Unable to set raid group mentor: [{}]\n", results.ErrorMessage().c_str());
}
void Raid::ClearGroupMentor(uint32 group_id)
@@ -1765,7 +1769,7 @@ void Raid::ClearGroupMentor(uint32 group_id)
group_id, GetID());
auto results = database.QueryDatabase(query);
if (!results.Success())
Log(Logs::General, Logs::Error, "Unable to clear raid group mentor: %s\n", results.ErrorMessage().c_str());
LogError("Unable to clear raid group mentor: [{}]\n", results.ErrorMessage().c_str());
}
// there isn't a nice place to add this in another function, unlike groups