diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp index 8895f48b9..ef740fb53 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp @@ -1857,6 +1857,7 @@ void CMagicPhrase::setPrimaryTarget( const TDataSetRow &entityRowId ) // virtual void CMagicPhrase::enchantPhrase(CCharacter * user,float successFactor) { H_AUTO(CMagicPhrase_enchantPhrase); + TLogContext_Item_EnchantPhrase(user->getId()); MBEHAV::CBehaviour behav; uint moneyCost = uint( getSabrinaCost() * CristalMoneyFactor ); 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 f06225c98..975b32104 100644 --- a/code/ryzom/server/src/server_share/log_item_gen.cpp +++ b/code/ryzom/server/src/server_share/log_item_gen.cpp @@ -1187,6 +1187,29 @@ TLogContext_Item_OutpostDriller::~TLogContext_Item_OutpostDriller() } +const std::string TLogContext_Item_EnchantPhrase::_ContextName("Item_EnchantPhrase"); +/// The constructor push a log context in the logger system +TLogContext_Item_EnchantPhrase::TLogContext_Item_EnchantPhrase(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_EnchantPhrase::~TLogContext_Item_EnchantPhrase() +{ + 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 13f2411d0..636f4cf17 100644 --- a/code/ryzom/server/src/server_share/log_item_gen.h +++ b/code/ryzom/server/src/server_share/log_item_gen.h @@ -383,6 +383,21 @@ private: static const std::string _ContextName; +}; + +struct TLogContext_Item_EnchantPhrase +{ + /// The constructor push a log context in the logger system + TLogContext_Item_EnchantPhrase(const NLMISC::CEntityId &charId); + + /// The desstructor pop a context in the logger system + ~TLogContext_Item_EnchantPhrase(); + +private: + /// The name of the context + static const std::string _ContextName; + + };