mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-09-05 14:58:27 +00:00
feat: Abstract Logger and simplify code (#1207)
* Logger: Rename logger to Logger from dLogger * Logger: Add compile time filename Fix include issues Add writers Add macros Add macro to force compilation * Logger: Replace calls with macros Allows for filename and line number to be logged * Logger: Add comments and remove extra define Logger: Replace with unique_ptr also flush console at exit. regular file writer should be flushed on file close. Logger: Remove constexpr on variable * Logger: Simplify code * Update Logger.cpp
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "dServer.h"
|
||||
#include "tinyxml2.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
#include "Logger.h"
|
||||
#include "BinaryPathFinder.h"
|
||||
#include "EntityInfo.h"
|
||||
|
||||
@@ -49,7 +49,7 @@ void VanityUtilities::SpawnVanity() {
|
||||
std::vector<VanityNPC> npcList = m_NPCs;
|
||||
std::vector<uint32_t> taken = {};
|
||||
|
||||
Game::logger->Log("VanityUtilities", "Spawning party with %i locations", party.m_Locations.size());
|
||||
LOG("Spawning party with %i locations", party.m_Locations.size());
|
||||
|
||||
// Loop through all locations
|
||||
for (const auto& location : party.m_Locations) {
|
||||
@@ -70,7 +70,7 @@ void VanityUtilities::SpawnVanity() {
|
||||
taken.push_back(npcIndex);
|
||||
|
||||
// Spawn the NPC
|
||||
Game::logger->Log("VanityUtilities", "ldf size is %i", npc.ldf.size());
|
||||
LOG("ldf size is %i", npc.ldf.size());
|
||||
if (npc.ldf.empty()) {
|
||||
npc.ldf = {
|
||||
new LDFData<std::vector<std::u16string>>(u"syncLDF", { u"custom_script_client" }),
|
||||
@@ -194,7 +194,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
auto* npcs = doc.FirstChildElement("npcs");
|
||||
|
||||
if (npcs == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPCs");
|
||||
LOG("Failed to parse NPCs");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
auto* locations = party->FirstChildElement("locations");
|
||||
|
||||
if (locations == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse party locations");
|
||||
LOG("Failed to parse party locations");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
|
||||
if (x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr
|
||||
|| rz == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse party location data");
|
||||
LOG("Failed to parse party location data");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
auto* partyPhrases = npcs->FirstChildElement("partyphrases");
|
||||
|
||||
if (partyPhrases == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse party phrases");
|
||||
LOG("Failed to parse party phrases");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
auto* text = phrase->GetText();
|
||||
|
||||
if (text == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse party phrase");
|
||||
LOG("Failed to parse party phrase");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
auto* lot = npc->Attribute("lot");
|
||||
|
||||
if (lot == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC lot");
|
||||
LOG("Failed to parse NPC lot");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
// Get the phrase
|
||||
auto* text = phrase->GetText();
|
||||
if (text == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC phrase");
|
||||
LOG("Failed to parse NPC phrase");
|
||||
continue;
|
||||
}
|
||||
phraseList.push_back(text);
|
||||
@@ -367,7 +367,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
auto* name = flag->Attribute("name");
|
||||
|
||||
if (name == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC flag name");
|
||||
LOG("Failed to parse NPC flag name");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
auto* value = flag->Attribute("value");
|
||||
|
||||
if (value == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC flag value");
|
||||
LOG("Failed to parse NPC flag value");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
auto* zoneID = zone->Attribute("id");
|
||||
|
||||
if (zoneID == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC zone ID");
|
||||
LOG("Failed to parse NPC zone ID");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
auto* locations = zone->FirstChildElement("locations");
|
||||
|
||||
if (locations == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC locations");
|
||||
LOG("Failed to parse NPC locations");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ void VanityUtilities::ParseXML(const std::string& file) {
|
||||
|
||||
if (x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr
|
||||
|| rz == nullptr) {
|
||||
Game::logger->Log("VanityUtilities", "Failed to parse NPC location data");
|
||||
LOG("Failed to parse NPC location data");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -478,8 +478,10 @@ std::string VanityUtilities::ParseMarkdown(const std::string& file) {
|
||||
while (std::getline(ss, line)) {
|
||||
|
||||
#define TOSTRING(x) #x
|
||||
#define STRINGIFY(x) TOSTRING(x)
|
||||
|
||||
#ifndef STRINGIFY
|
||||
#define STRINGIFY(x) TOSTRING(x)
|
||||
#endif
|
||||
// Replace "__TIMESTAMP__" with the __TIMESTAMP__
|
||||
GeneralUtils::ReplaceInString(line, "__TIMESTAMP__", __TIMESTAMP__);
|
||||
// Replace "__VERSION__" wit'h the PROJECT_VERSION
|
||||
|
Reference in New Issue
Block a user