Add item logging context for enchanting items

ryzomclassic-develop
kaetemi 5 years ago
parent 1dce83d279
commit aec03f6234

@ -2724,6 +2724,8 @@ void CCharacter::enchantItem(INVENTORIES::TInventory invId, uint32 slot)
{ {
if (checkSlotsForEnchantOrRecharge(invId, slot, true)) if (checkSlotsForEnchantOrRecharge(invId, slot, true))
{ {
TLogContext_Item_EnchantItem logContext(_Id);
CInventoryPtr inv = getInventory(invId); CInventoryPtr inv = getInventory(invId);
CInventoryPtr handlingInv = getInventory(INVENTORIES::handling); CInventoryPtr handlingInv = getInventory(INVENTORIES::handling);
nlassert(inv != NULL); nlassert(inv != NULL);

@ -52,7 +52,7 @@ public:
CItemDesc() CItemDesc()
: _NoContextCount(0) : _NoContextCount(0)
{ {
_LogDefs.resize(37); _LogDefs.resize(38);
{ {
LGS::TLogDefinition &logDef = _LogDefs[0]; LGS::TLogDefinition &logDef = _LogDefs[0];
@ -576,6 +576,15 @@ public:
logDef.setContext(true); logDef.setContext(true);
} }
{
LGS::TLogDefinition &logDef = _LogDefs[37];
logDef.setLogName("Item_EnchantItem");
logDef.setLogText("A player character enchants an item with a crystallized spell phrase");
logDef.setContext(true);
}
// Register the log definitions // Register the log definitions
@ -1283,6 +1292,29 @@ TLogContext_Item_EnchantPhrase::~TLogContext_Item_EnchantPhrase()
} }
const std::string TLogContext_Item_EnchantItem::_ContextName("Item_EnchantItem");
/// The constructor push a log context in the logger system
TLogContext_Item_EnchantItem::TLogContext_Item_EnchantItem(const NLMISC::CEntityId &charId)
{
if (LGS::ILoggerServiceClient::isInitialized())
LGS::ILoggerServiceClient::getInstance()->pushLogContext(_ContextName);
// stack the context param in the context class object
ItemDesc.pushContextVar_charId(charId);
}
/// The destructor pop a context in the logger system
TLogContext_Item_EnchantItem::~TLogContext_Item_EnchantItem()
{
if (LGS::ILoggerServiceClient::isInitialized())
LGS::ILoggerServiceClient::getInstance()->popLogContext(_ContextName);
// pop the context param in the context class object
ItemDesc.popContextVar_charId();
}
/// No context context. Use this to disable any contextual log underneath /// No context context. Use this to disable any contextual log underneath
TLogNoContext_Item::TLogNoContext_Item() TLogNoContext_Item::TLogNoContext_Item()

@ -428,6 +428,21 @@ private:
static const std::string _ContextName; static const std::string _ContextName;
};
struct TLogContext_Item_EnchantItem
{
/// The constructor push a log context in the logger system
TLogContext_Item_EnchantItem(const NLMISC::CEntityId &charId);
/// The desstructor pop a context in the logger system
~TLogContext_Item_EnchantItem();
private:
/// The name of the context
static const std::string _ContextName;
}; };

Loading…
Cancel
Save