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
+4 -4
View File
@@ -64,7 +64,7 @@ bool Database::Connect(const char* host, const char* user, const char* passwd, c
uint32 errnum= 0;
char errbuf[MYSQL_ERRMSG_SIZE];
if (!Open(host, user, passwd, database, port, &errnum, errbuf)) {
Log(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf);
LogError("Failed to connect to database: Error: {}", errbuf);
return false;
}
else {
@@ -327,7 +327,7 @@ bool Database::DeleteCharacter(char *name) {
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { charid = atoi(row[0]); }
if (charid <= 0){
Log(Logs::General, Logs::Error, "Database::DeleteCharacter :: Character (%s) not found, stopping delete...", name);
LogError("Database::DeleteCharacter :: Character ({}) not found, stopping delete...", name);
return false;
}
@@ -714,7 +714,7 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQEmu
charid = GetCharacterID(pp->name);
if(!charid) {
Log(Logs::General, Logs::Error, "StoreCharacter: no character id");
LogError("StoreCharacter: no character id");
return false;
}
@@ -1551,7 +1551,7 @@ void Database::SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ism
auto results = QueryDatabase(query);
if (!results.Success())
Log(Logs::General, Logs::Error, "Error deleting character from group id: %s", results.ErrorMessage().c_str());
LogError("Error deleting character from group id: {}", results.ErrorMessage().c_str());
return;
}
+1 -1
View File
@@ -1381,7 +1381,7 @@ int16 EQEmu::InventoryProfile::_PutItem(int16 slot_id, ItemInstance* inst)
}
if (result == INVALID_INDEX) {
Log(Logs::General, Logs::Error, "InventoryProfile::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot);
LogError("InventoryProfile::_PutItem: Invalid slot_id specified ({}) with parent slot id ({})", slot_id, parentSlot);
InventoryProfile::MarkDirty(inst); // Slot not found, clean up
}
+1 -1
View File
@@ -32,7 +32,7 @@ OpcodeManager::OpcodeManager() {
bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors) {
FILE *opf = fopen(filename, "r");
if(opf == nullptr) {
Log(Logs::General, Logs::Error, "Unable to open opcodes file '%s'", filename);
LogError("Unable to open opcodes file [{}]", filename);
return(false);
}
+1 -17
View File
@@ -134,7 +134,6 @@ bool PersistentTimer::Load(Database *db) {
(unsigned long)_char_id, _type);
auto results = db->QueryDatabase(query);
if (!results.Success()) {
Log(Logs::General, Logs::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str());
return false;
}
@@ -165,9 +164,6 @@ bool PersistentTimer::Store(Database *db) {
#endif
auto results = db->QueryDatabase(query);
if (!results.Success()) {
#if EQDEBUG > 5
Log(Logs::General, Logs::Error, "Error in PersistentTimer::Store, error: %s", results.ErrorMessage().c_str());
#endif
return false;
}
@@ -185,9 +181,6 @@ bool PersistentTimer::Clear(Database *db) {
auto results = db->QueryDatabase(query);
if (!results.Success()) {
#if EQDEBUG > 5
Log(Logs::General, Logs::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str());
#endif
return false;
}
@@ -198,7 +191,7 @@ bool PersistentTimer::Clear(Database *db) {
/* This function checks if the timer triggered */
bool PersistentTimer::Expired(Database *db, bool iReset) {
if (this == nullptr) {
Log(Logs::General, Logs::Error, "Null timer during ->Check()!?\n");
LogError("Null timer during ->Check()!?\n");
return(true);
}
uint32 current_time = get_current_time();
@@ -289,9 +282,6 @@ bool PTimerList::Load(Database *db) {
(unsigned long)_char_id);
auto results = db->QueryDatabase(query);
if (!results.Success()) {
#if EQDEBUG > 5
Log(Logs::General, Logs::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str());
#endif
return false;
}
@@ -348,9 +338,6 @@ bool PTimerList::Clear(Database *db) {
#endif
auto results = db->QueryDatabase(query);
if (!results.Success()) {
#if EQDEBUG > 5
Log(Logs::General, Logs::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str());
#endif
return false;
}
@@ -440,9 +427,6 @@ bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) {
#endif
auto results = db->QueryDatabase(query);
if (!results.Success()) {
#if EQDEBUG > 5
Log(Logs::General, Logs::Error, "Error in PTimerList::ClearOffline, error: %s", results.ErrorMessage().c_str());
#endif
return false;
}
+5 -5
View File
@@ -100,8 +100,8 @@ const std::string &EQEmu::SayLinkEngine::GenerateLink()
if ((m_Link.length() == 0) || (m_Link.length() > (EQEmu::constants::SAY_LINK_MAXIMUM_SIZE))) {
m_Error = true;
m_Link = "<LINKER ERROR>";
Log(Logs::General, Logs::Error, "SayLinkEngine::GenerateLink() failed to generate a useable say link");
Log(Logs::General, Logs::Error, ">> LinkType: %i, Lengths: {link: %u(%u), body: %u(%u), text: %u(%u)}",
LogError("SayLinkEngine::GenerateLink() failed to generate a useable say link");
LogError(">> LinkType: {}, Lengths: {link: {}({}), body: {}({}), text: {}({})}",
m_LinkType,
m_Link.length(),
EQEmu::constants::SAY_LINK_MAXIMUM_SIZE,
@@ -110,8 +110,8 @@ const std::string &EQEmu::SayLinkEngine::GenerateLink()
m_LinkText.length(),
EQEmu::constants::SAY_LINK_TEXT_SIZE
);
Log(Logs::General, Logs::Error, ">> LinkBody: %s", m_LinkBody.c_str());
Log(Logs::General, Logs::Error, ">> LinkText: %s", m_LinkText.c_str());
LogError(">> LinkBody: {}", m_LinkBody.c_str());
LogError(">> LinkText: {}", m_LinkText.c_str());
}
return m_Link;
@@ -316,7 +316,7 @@ std::string EQEmu::SayLinkEngine::GenerateQuestSaylink(std::string saylink_text,
results = database.QueryDatabase(insert_query);
if (!results.Success()) {
Log(Logs::General, Logs::Error, "Error in saylink phrase queries %s", results.ErrorMessage().c_str());
LogError("Error in saylink phrase queries {}", results.ErrorMessage().c_str());
}
else {
saylink_id = results.LastInsertedID();
+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;
}