From 2cb353438bab99992fc9ce1ab7185540b2465a35 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 18 Nov 2019 20:19:35 +0800 Subject: [PATCH] Add log context for sale store check --- .../shop_type/items_for_sale.cpp | 1 + .../server/src/server_share/log_item_gen.cpp | 34 ++++++++++++++++++- .../server/src/server_share/log_item_gen.h | 15 ++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp b/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp index 61538b674..6f2234f1e 100644 --- a/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp +++ b/code/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp @@ -107,6 +107,7 @@ void CItemsForSale::serial(NLMISC::IStream &f) //----------------------------------------------------------------------------- void CItemsForSale::checkSellStore( CEntityId charId ) { + TLogContext_Item_CheckSaleStore itemStoreContext(charId); std::vector< TItemTradePtr > itemsForSaleOfCharacter; std::vector< TItemTradePtr > itemsOfCharacterMustBeRemoved; CDynamicItems::getInstance()->getItemsOfCharacter( charId, itemsForSaleOfCharacter ); 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 885b34342..853fb303c 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(35); + _LogDefs.resize(36); { LGS::TLogDefinition &logDef = _LogDefs[0]; @@ -558,6 +558,15 @@ public: logDef.setContext(true); } + + { + LGS::TLogDefinition &logDef = _LogDefs[35]; + + logDef.setLogName("Item_CheckSaleStore"); + logDef.setLogText("Check coherency between player and sale store"); + + logDef.setContext(true); + } // Register the log definitions @@ -964,6 +973,29 @@ TLogContext_Item_SaleStoreTimeout::~TLogContext_Item_SaleStoreTimeout() } +const std::string TLogContext_Item_CheckSaleStore::_ContextName("Item_CheckSaleStore"); +/// The constructor push a log context in the logger system +TLogContext_Item_CheckSaleStore::TLogContext_Item_CheckSaleStore(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_CheckSaleStore::~TLogContext_Item_CheckSaleStore() +{ + if (LGS::ILoggerServiceClient::isInitialized()) + LGS::ILoggerServiceClient::getInstance()->popLogContext(_ContextName); + + // pop the context param in the context class object + ItemDesc.popContextVar_charId(); + +} + const std::string TLogContext_Item_ConsumeAmmo::_ContextName("Item_ConsumeAmmo"); /// The constructor push a log context in the logger system TLogContext_Item_ConsumeAmmo::TLogContext_Item_ConsumeAmmo(const NLMISC::CEntityId &charId) 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 636f4cf17..06c59302e 100644 --- a/code/ryzom/server/src/server_share/log_item_gen.h +++ b/code/ryzom/server/src/server_share/log_item_gen.h @@ -233,6 +233,21 @@ private: static const std::string _ContextName; +}; + +struct TLogContext_Item_CheckSaleStore +{ + /// The constructor push a log context in the logger system + TLogContext_Item_CheckSaleStore(const NLMISC::CEntityId &charId); + + /// The desstructor pop a context in the logger system + ~TLogContext_Item_CheckSaleStore(); + +private: + /// The name of the context + static const std::string _ContextName; + + }; struct TLogContext_Item_ConsumeAmmo