Simplify log calls

This commit is contained in:
Akkadius
2019-09-01 21:04:58 -05:00
parent d3803045bc
commit 98cbb7d781
21 changed files with 113 additions and 135 deletions
+26 -30
View File
@@ -123,7 +123,7 @@ void SharedDatabase::SetMailKey(int CharID, int IPAddress, int MailKey)
MailKeyString, CharID);
auto results = QueryDatabase(query);
if (!results.Success())
Log(Logs::General, Logs::Error, "SharedDatabase::SetMailKey(%i, %s) : %s", CharID, MailKeyString, results.ErrorMessage().c_str());
LogError("SharedDatabase::SetMailKey({}, {}) : {}", CharID, MailKeyString, results.ErrorMessage().c_str());
}
@@ -466,8 +466,6 @@ bool SharedDatabase::GetSharedBank(uint32 id, EQEmu::InventoryProfile *inv, bool
id);
auto results = QueryDatabase(query);
if (!results.Success()) {
Log(Logs::General, Logs::Error, "Database::GetSharedBank(uint32 account_id): %s",
results.ErrorMessage().c_str());
return false;
}
@@ -561,7 +559,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv)
char_id);
auto results = QueryDatabase(query);
if (!results.Success()) {
Log(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the "
LogError("If you got an error related to the 'instnodrop' field, run the "
"following SQL Queries:\nalter table inventory add instnodrop "
"tinyint(1) unsigned default 0 not null;\n");
return false;
@@ -699,8 +697,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv)
put_slot_id = inv->PushCursor(*inst);
} else if (slot_id >= 3111 && slot_id <= 3179) {
// Admins: please report any occurrences of this error
Log(Logs::General, Logs::Error, "Warning: Defunct location for item in inventory: "
"charid=%i, item_id=%i, slot_id=%i .. pushing to cursor...",
LogError("Warning: Defunct location for item in inventory: charid={}, item_id={}, slot_id={} .. pushing to cursor...",
char_id, item_id, slot_id);
put_slot_id = inv->PushCursor(*inst);
} else {
@@ -746,7 +743,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQEmu::Inventor
name, account_id);
auto results = QueryDatabase(query);
if (!results.Success()) {
Log(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the "
LogError("If you got an error related to the 'instnodrop' field, run the "
"following SQL Queries:\nalter table inventory add instnodrop "
"tinyint(1) unsigned default 0 not null;\n");
return false;
@@ -834,8 +831,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQEmu::Inventor
// Save ptr to item in inventory
if (put_slot_id == INVALID_INDEX)
Log(Logs::General, Logs::Error, "Warning: Invalid slot_id for item in inventory: name=%s, "
"acctid=%i, item_id=%i, slot_id=%i",
LogError("Warning: Invalid slot_id for item in inventory: name={}, acctid={}, item_id={}, slot_id={}",
name, account_id, item_id, slot_id);
}
@@ -911,7 +907,7 @@ bool SharedDatabase::LoadItems(const std::string &prefix) {
items_hash = std::unique_ptr<EQEmu::FixedMemoryHashSet<EQEmu::ItemData>>(new EQEmu::FixedMemoryHashSet<EQEmu::ItemData>(reinterpret_cast<uint8*>(items_mmf->Get()), items_mmf->Size()));
mutex.Unlock();
} catch(std::exception& ex) {
Log(Logs::General, Logs::Error, "Error Loading Items: %s", ex.what());
LogError("Error Loading Items: {}", ex.what());
return false;
}
@@ -1172,7 +1168,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
try {
hash.insert(item.ID, item);
} catch (std::exception &ex) {
Log(Logs::General, Logs::Error, "Database::LoadItems: %s", ex.what());
LogError("Database::LoadItems: {}", ex.what());
break;
}
}
@@ -1229,7 +1225,7 @@ std::string SharedDatabase::GetBook(const char *txtfile, int16 *language)
}
if (results.RowCount() == 0) {
Log(Logs::General, Logs::Error, "No book to send, (%s)", txtfile);
LogError("No book to send, ({})", txtfile);
txtout.assign(" ",1);
return txtout;
}
@@ -1334,7 +1330,7 @@ bool SharedDatabase::LoadNPCFactionLists(const std::string &prefix) {
faction_hash = std::unique_ptr<EQEmu::FixedMemoryHashSet<NPCFactionList>>(new EQEmu::FixedMemoryHashSet<NPCFactionList>(reinterpret_cast<uint8*>(faction_mmf->Get()), faction_mmf->Size()));
mutex.Unlock();
} catch(std::exception& ex) {
Log(Logs::General, Logs::Error, "Error Loading npc factions: %s", ex.what());
LogError("Error Loading npc factions: {}", ex.what());
return false;
}
@@ -1352,8 +1348,8 @@ EQEmu::ItemInstance* SharedDatabase::CreateItem(uint32 item_id, int16 charges, u
inst = CreateBaseItem(item, charges);
if (inst == nullptr) {
Log(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()");
Log(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
LogError("Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()");
LogError("Item Data = ID: {}, Name: {}, Charges: {}", item->ID, item->Name, charges);
return nullptr;
}
@@ -1378,8 +1374,8 @@ EQEmu::ItemInstance* SharedDatabase::CreateItem(const EQEmu::ItemData* item, int
inst = CreateBaseItem(item, charges);
if (inst == nullptr) {
Log(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()");
Log(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
LogError("Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()");
LogError("Item Data = ID: {}, Name: {}, Charges: {}", item->ID, item->Name, charges);
return nullptr;
}
@@ -1409,8 +1405,8 @@ EQEmu::ItemInstance* SharedDatabase::CreateBaseItem(const EQEmu::ItemData* item,
inst = new EQEmu::ItemInstance(item, charges);
if (inst == nullptr) {
Log(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateBaseItem()");
Log(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
LogError("Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateBaseItem()");
LogError("Item Data = ID: {}, Name: {}, Charges: {}", item->ID, item->Name, charges);
return nullptr;
}
@@ -1485,7 +1481,7 @@ bool SharedDatabase::LoadSkillCaps(const std::string &prefix) {
skill_caps_mmf = std::unique_ptr<EQEmu::MemoryMappedFile>(new EQEmu::MemoryMappedFile(file_name));
mutex.Unlock();
} catch(std::exception &ex) {
Log(Logs::General, Logs::Error, "Error loading skill caps: %s", ex.what());
LogError("Error loading skill caps: {}", ex.what());
return false;
}
@@ -1501,7 +1497,7 @@ void SharedDatabase::LoadSkillCaps(void *data) {
const std::string query = "SELECT skillID, class, level, cap FROM skill_caps ORDER BY skillID, class, level";
auto results = QueryDatabase(query);
if (!results.Success()) {
Log(Logs::General, Logs::Error, "Error loading skill caps from database: %s", results.ErrorMessage().c_str());
LogError("Error loading skill caps from database: {}", results.ErrorMessage().c_str());
return;
}
@@ -1645,7 +1641,7 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const
mutex.Unlock();
}
catch(std::exception& ex) {
Log(Logs::General, Logs::Error, "Error Loading Spells: %s", ex.what());
LogError("Error Loading Spells: {}", ex.what());
return false;
}
return true;
@@ -1849,7 +1845,7 @@ bool SharedDatabase::LoadBaseData(const std::string &prefix) {
base_data_mmf = std::unique_ptr<EQEmu::MemoryMappedFile>(new EQEmu::MemoryMappedFile(file_name));
mutex.Unlock();
} catch(std::exception& ex) {
Log(Logs::General, Logs::Error, "Error Loading Base Data: %s", ex.what());
LogError("Error Loading Base Data: {}", ex.what());
return false;
}
@@ -1873,22 +1869,22 @@ void SharedDatabase::LoadBaseData(void *data, int max_level) {
cl = atoi(row[1]);
if(lvl <= 0) {
Log(Logs::General, Logs::Error, "Non fatal error: base_data.level <= 0, ignoring.");
LogError("Non fatal error: base_data.level <= 0, ignoring.");
continue;
}
if(lvl >= max_level) {
Log(Logs::General, Logs::Error, "Non fatal error: base_data.level >= max_level, ignoring.");
LogError("Non fatal error: base_data.level >= max_level, ignoring.");
continue;
}
if(cl <= 0) {
Log(Logs::General, Logs::Error, "Non fatal error: base_data.cl <= 0, ignoring.");
LogError("Non fatal error: base_data.cl <= 0, ignoring.");
continue;
}
if(cl > 16) {
Log(Logs::General, Logs::Error, "Non fatal error: base_data.class > 16, ignoring.");
LogError("Non fatal error: base_data.class > 16, ignoring.");
continue;
}
@@ -2096,7 +2092,7 @@ bool SharedDatabase::LoadLoot(const std::string &prefix) {
loot_drop_mmf->Size()));
mutex.Unlock();
} catch(std::exception &ex) {
Log(Logs::General, Logs::Error, "Error loading loot: %s", ex.what());
LogError("Error loading loot: {}", ex.what());
return false;
}
@@ -2112,7 +2108,7 @@ const LootTable_Struct* SharedDatabase::GetLootTable(uint32 loottable_id) {
return &loot_table_hash->at(loottable_id);
}
} catch(std::exception &ex) {
Log(Logs::General, Logs::Error, "Could not get loot table: %s", ex.what());
LogError("Could not get loot table: {}", ex.what());
}
return nullptr;
}
@@ -2126,7 +2122,7 @@ const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) {
return &loot_drop_hash->at(lootdrop_id);
}
} catch(std::exception &ex) {
Log(Logs::General, Logs::Error, "Could not get loot drop: %s", ex.what());
LogError("Could not get loot drop: {}", ex.what());
}
return nullptr;
}