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:
David Markowitz
2023-10-21 16:31:55 -07:00
committed by GitHub
parent 131239538b
commit 5942182486
160 changed files with 1013 additions and 985 deletions

View File

@@ -4,7 +4,7 @@
#include "LeaderboardManager.h"
#include "GameMessages.h"
#include <algorithm>
#include "dLogger.h"
#include "Logger.h"
#include "Loot.h"
bool ActivityManager::IsPlayerInActivity(Entity* self, LWOOBJID playerID) {
@@ -129,7 +129,7 @@ void ActivityManager::ActivityTimerStart(Entity* self, const std::string& timerN
auto* timer = new ActivityTimer{ timerName, updateInterval, stopTime };
activeTimers.push_back(timer);
Game::logger->LogDebug("ActivityManager", "Starting timer '%s', %f, %f", timerName.c_str(), updateInterval, stopTime);
LOG_DEBUG("Starting timer '%s', %f, %f", timerName.c_str(), updateInterval, stopTime);
self->AddTimer(GetPrefixedName(timer->name), timer->updateInterval);
}
@@ -210,10 +210,10 @@ void ActivityManager::OnTimerDone(Entity* self, std::string timerName) {
activeTimers.erase(std::remove(activeTimers.begin(), activeTimers.end(), timer),
activeTimers.end());
delete timer;
Game::logger->LogDebug("ActivityManager", "Executing timer '%s'", activityTimerName.c_str());
LOG_DEBUG("Executing timer '%s'", activityTimerName.c_str());
OnActivityTimerDone(self, activityTimerName);
} else {
Game::logger->LogDebug("ActivityManager", "Updating timer '%s'", activityTimerName.c_str());
LOG_DEBUG("Updating timer '%s'", activityTimerName.c_str());
OnActivityTimerUpdate(self, timer->name, timer->stopTime - timer->runTime, timer->runTime);
self->AddTimer(GetPrefixedName(timer->name), timer->updateInterval);
}