mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +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:
@@ -9,5 +9,5 @@ AddActionMessage::AddActionMessage(AMFArrayValue* arguments) : BehaviorMessageBa
|
||||
|
||||
action = Action(actionValue);
|
||||
|
||||
Game::logger->LogDebug("AddActionMessage", "actionIndex %i stripId %i stateId %i type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i", actionIndex, actionContext.GetStripId(), actionContext.GetStateId(), action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId);
|
||||
LOG_DEBUG("actionIndex %i stripId %i stateId %i type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i", actionIndex, actionContext.GetStripId(), actionContext.GetStateId(), action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId);
|
||||
}
|
||||
|
@@ -7,5 +7,5 @@ AddMessage::AddMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetValue());
|
||||
Game::logger->LogDebug("AddMessage", "behaviorId %i index %i", behaviorId, behaviorIndex);
|
||||
LOG_DEBUG("behaviorId %i index %i", behaviorId, behaviorIndex);
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ AddStripMessage::AddStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase
|
||||
|
||||
actionsToAdd.push_back(Action(actionValue));
|
||||
|
||||
Game::logger->LogDebug("AddStripMessage", "xPosition %f yPosition %f stripId %i stateId %i behaviorId %i t %s valueParameterName %s valueParameterString %s valueParameterDouble %f", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId, actionsToAdd.back().GetType().c_str(), actionsToAdd.back().GetValueParameterName().c_str(), actionsToAdd.back().GetValueParameterString().c_str(), actionsToAdd.back().GetValueParameterDouble());
|
||||
LOG_DEBUG("xPosition %f yPosition %f stripId %i stateId %i behaviorId %i t %s valueParameterName %s valueParameterString %s valueParameterDouble %f", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId, actionsToAdd.back().GetType().c_str(), actionsToAdd.back().GetValueParameterName().c_str(), actionsToAdd.back().GetValueParameterString().c_str(), actionsToAdd.back().GetValueParameterDouble());
|
||||
}
|
||||
Game::logger->Log("AddStripMessage", "number of actions %i", actionsToAdd.size());
|
||||
LOG_DEBUG("number of actions %i", actionsToAdd.size());
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include "dCommonVars.h"
|
||||
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
#include "Logger.h"
|
||||
|
||||
enum class BehaviorState : uint32_t;
|
||||
|
||||
|
@@ -6,6 +6,6 @@ MergeStripsMessage::MergeStripsMessage(AMFArrayValue* arguments) : BehaviorMessa
|
||||
destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID");
|
||||
dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex");
|
||||
|
||||
Game::logger->LogDebug("MergeStripsMessage", "srcstripId %i dststripId %i srcstateId %i dststateId %i dstactionIndex %i behaviorId %i", sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), dstActionIndex, behaviorId);
|
||||
LOG_DEBUG("srcstripId %i dststripId %i srcstateId %i dststateId %i dstactionIndex %i behaviorId %i", sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), dstActionIndex, behaviorId);
|
||||
}
|
||||
|
||||
|
@@ -7,5 +7,5 @@ MigrateActionsMessage::MigrateActionsMessage(AMFArrayValue* arguments) : Behavio
|
||||
destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID");
|
||||
dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex");
|
||||
|
||||
Game::logger->LogDebug("MigrateActionsMessage", "srcactionIndex %i dstactionIndex %i srcstripId %i dststripId %i srcstateId %i dststateId %i behaviorId %i", srcActionIndex, dstActionIndex, sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), behaviorId);
|
||||
LOG_DEBUG("srcactionIndex %i dstactionIndex %i srcstripId %i dststripId %i srcstateId %i dststateId %i behaviorId %i", srcActionIndex, dstActionIndex, sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), behaviorId);
|
||||
}
|
||||
|
@@ -5,5 +5,5 @@ MoveToInventoryMessage::MoveToInventoryMessage(AMFArrayValue* arguments) : Behav
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetValue());
|
||||
Game::logger->LogDebug("MoveToInventoryMessage", "behaviorId %i behaviorIndex %i", behaviorId, behaviorIndex);
|
||||
LOG_DEBUG("behaviorId %i behaviorIndex %i", behaviorId, behaviorIndex);
|
||||
}
|
||||
|
@@ -6,5 +6,5 @@ RearrangeStripMessage::RearrangeStripMessage(AMFArrayValue* arguments) : Behavio
|
||||
|
||||
dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex");
|
||||
|
||||
Game::logger->LogDebug("RearrangeStripMessage", "srcactionIndex %i dstactionIndex %i stripId %i behaviorId %i stateId %i", srcActionIndex, dstActionIndex, actionContext.GetStripId(), behaviorId, actionContext.GetStateId());
|
||||
LOG_DEBUG("srcactionIndex %i dstactionIndex %i stripId %i behaviorId %i stateId %i", srcActionIndex, dstActionIndex, actionContext.GetStripId(), behaviorId, actionContext.GetStateId());
|
||||
}
|
||||
|
@@ -4,5 +4,5 @@ RemoveActionsMessage::RemoveActionsMessage(AMFArrayValue* arguments) : BehaviorM
|
||||
actionContext = ActionContext(arguments);
|
||||
actionIndex = GetActionIndexFromArgument(arguments);
|
||||
|
||||
Game::logger->LogDebug("RemoveActionsMessage", "behaviorId %i actionIndex %i stripId %i stateId %i", behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId());
|
||||
LOG_DEBUG("behaviorId %i actionIndex %i stripId %i stateId %i", behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId());
|
||||
}
|
||||
|
@@ -3,5 +3,5 @@
|
||||
RemoveStripMessage::RemoveStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
actionContext = ActionContext(arguments);
|
||||
|
||||
Game::logger->LogDebug("RemoveStripMessage", "stripId %i stateId %i behaviorId %i", actionContext.GetStripId(), actionContext.GetStateId(), behaviorId);
|
||||
LOG_DEBUG("stripId %i stateId %i behaviorId %i", actionContext.GetStripId(), actionContext.GetStateId(), behaviorId);
|
||||
}
|
||||
|
@@ -5,5 +5,5 @@ RenameMessage::RenameMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arg
|
||||
if (!nameAmf) return;
|
||||
|
||||
name = nameAmf->GetValue();
|
||||
Game::logger->LogDebug("RenameMessage", "behaviorId %i n %s", behaviorId, name.c_str());
|
||||
LOG_DEBUG("behaviorId %i n %s", behaviorId, name.c_str());
|
||||
}
|
||||
|
@@ -7,5 +7,5 @@ SplitStripMessage::SplitStripMessage(AMFArrayValue* arguments) : BehaviorMessage
|
||||
destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID");
|
||||
destinationPosition = StripUiPosition(arguments, "dstStripUI");
|
||||
|
||||
Game::logger->LogDebug("SplitStripMessage", "behaviorId %i xPosition %f yPosition %f sourceStrip %i destinationStrip %i sourceState %i destinationState %i srcActindex %i", behaviorId, destinationPosition.GetX(), destinationPosition.GetY(), sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), srcActionIndex);
|
||||
LOG_DEBUG("behaviorId %i xPosition %f yPosition %f sourceStrip %i destinationStrip %i sourceState %i destinationState %i srcActindex %i", behaviorId, destinationPosition.GetX(), destinationPosition.GetY(), sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), srcActionIndex);
|
||||
}
|
||||
|
@@ -11,5 +11,5 @@ UpdateActionMessage::UpdateActionMessage(AMFArrayValue* arguments) : BehaviorMes
|
||||
action = Action(actionValue);
|
||||
actionIndex = GetActionIndexFromArgument(arguments);
|
||||
|
||||
Game::logger->LogDebug("UpdateActionMessage", "type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i actionIndex %i stripId %i stateId %i", action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId());
|
||||
LOG_DEBUG("type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i actionIndex %i stripId %i stateId %i", action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId());
|
||||
}
|
||||
|
@@ -4,5 +4,5 @@ UpdateStripUiMessage::UpdateStripUiMessage(AMFArrayValue* arguments) : BehaviorM
|
||||
position = StripUiPosition(arguments);
|
||||
actionContext = ActionContext(arguments);
|
||||
|
||||
Game::logger->LogDebug("UpdateStripUIMessage", "xPosition %f yPosition %f stripId %i stateId %i behaviorId %i", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId);
|
||||
LOG_DEBUG("xPosition %f yPosition %f stripId %i stateId %i behaviorId %i", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId);
|
||||
}
|
||||
|
Reference in New Issue
Block a user