diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_action_item_charge.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_action_item_charge.cpp index b940c5a1b..762f4ef9a 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_action_item_charge.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_action_item_charge.cpp @@ -97,6 +97,8 @@ protected: if ( !user ) return; + TLogContext_Item_RechargeSapLoad logContext(user->getId()); + uint moneyCost = uint( phrase->getSabrinaCost() * RechargeMoneyFactor ); if ( ! moneyCost ) moneyCost = 1; diff --git a/code/ryzom/server/src/server_share/log_item_gen.cpp b/code/ryzom/server/src/server_share/log_item_gen.cpp index ce328a780..7ca06e1b8 100644 --- a/code/ryzom/server/src/server_share/log_item_gen.cpp +++ b/code/ryzom/server/src/server_share/log_item_gen.cpp @@ -52,7 +52,7 @@ public: CItemDesc() : _NoContextCount(0) { - _LogDefs.resize(38); + _LogDefs.resize(39); { LGS::TLogDefinition &logDef = _LogDefs[0]; @@ -585,6 +585,15 @@ public: logDef.setContext(true); } + + { + LGS::TLogDefinition &logDef = _LogDefs[38]; + + logDef.setLogName("Item_RechargeSapLoad"); + logDef.setLogText("A player character recharges the sap load of an item"); + + logDef.setContext(true); + } // Register the log definitions @@ -1315,6 +1324,29 @@ TLogContext_Item_EnchantItem::~TLogContext_Item_EnchantItem() } +const std::string TLogContext_Item_RechargeSapLoad::_ContextName("Item_RechargeSapLoad"); +/// The constructor push a log context in the logger system +TLogContext_Item_RechargeSapLoad::TLogContext_Item_RechargeSapLoad(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_RechargeSapLoad::~TLogContext_Item_RechargeSapLoad() +{ + 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 TLogNoContext_Item::TLogNoContext_Item() diff --git a/code/ryzom/server/src/server_share/log_item_gen.h b/code/ryzom/server/src/server_share/log_item_gen.h index 994c0b192..64b474756 100644 --- a/code/ryzom/server/src/server_share/log_item_gen.h +++ b/code/ryzom/server/src/server_share/log_item_gen.h @@ -443,6 +443,21 @@ private: static const std::string _ContextName; +}; + +struct TLogContext_Item_RechargeSapLoad +{ + /// The constructor push a log context in the logger system + TLogContext_Item_RechargeSapLoad(const NLMISC::CEntityId &charId); + + /// The desstructor pop a context in the logger system + ~TLogContext_Item_RechargeSapLoad(); + +private: + /// The name of the context + static const std::string _ContextName; + + };