Add infos into target window
[ryzomcore.git] / ryzom / server / src / server_share / log_character_gen.cpp
bloba3433f9533f74cd3b3f0e177526b9b3096308d29
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "stdpch.h"
21 #include "game_share/utils.h"
22 #include "log_character_gen.h"
25 #include "logger_service_itf.h"
26 #include "logger_service_client.h"
28 // A function fo force linking of this code module
29 void forceLink_Character(){}
34 class CCharacterDesc
36 friend class CLoggerClient;
38 /// The list of log definition for this log class
39 std::vector<LGS::TLogDefinition> _LogDefs;
41 /// Stack of context variable
43 std::vector<NLMISC::CEntityId> _charId;
46 /// Counter of 'no context' object stacked.
47 uint32 _NoContextCount;
49 public:
50 /// constructor
51 CCharacterDesc()
52 : _NoContextCount(0)
54 _LogDefs.resize(11);
57 LGS::TLogDefinition &logDef = _LogDefs[0];
59 logDef.setLogName("Character_BuyRolemasterPhrase");
61 logDef.setContext(true);
67 LGS::TLogDefinition &logDef = _LogDefs[1];
69 logDef.setLogName("Character_AdminCommand");
71 logDef.setContext(true);
77 LGS::TLogDefinition &logDef = _LogDefs[2];
79 logDef.setLogName("Character_SkillProgress");
81 logDef.setContext(true);
87 LGS::TLogDefinition &logDef = _LogDefs[3];
89 logDef.setLogName("Character_MissionRecvXp");
91 logDef.setContext(true);
97 LGS::TLogDefinition &logDef = _LogDefs[4];
101 logDef.setLogName("Character_Create");
102 logDef.setLogText("Character Created");
104 logDef.getParams().resize(3);
105 logDef.getListParams().resize(0);
108 logDef.getParams()[0].setName("userId");
109 logDef.getParams()[0].setType(LGS::TSupportedParamType::spt_uint32);
110 logDef.getParams()[0].setList(false);
112 logDef.getParams()[1].setName("charId");
113 logDef.getParams()[1].setType(LGS::TSupportedParamType::spt_entityId);
114 logDef.getParams()[1].setList(false);
116 logDef.getParams()[2].setName("charName");
117 logDef.getParams()[2].setType(LGS::TSupportedParamType::spt_string);
118 logDef.getParams()[2].setList(false);
123 LGS::TLogDefinition &logDef = _LogDefs[5];
127 logDef.setLogName("Character_Delete");
128 logDef.setLogText("Character deleted");
130 logDef.getParams().resize(3);
131 logDef.getListParams().resize(0);
134 logDef.getParams()[0].setName("userId");
135 logDef.getParams()[0].setType(LGS::TSupportedParamType::spt_uint32);
136 logDef.getParams()[0].setList(false);
138 logDef.getParams()[1].setName("charId");
139 logDef.getParams()[1].setType(LGS::TSupportedParamType::spt_entityId);
140 logDef.getParams()[1].setList(false);
142 logDef.getParams()[2].setName("charName");
143 logDef.getParams()[2].setType(LGS::TSupportedParamType::spt_string);
144 logDef.getParams()[2].setList(false);
149 LGS::TLogDefinition &logDef = _LogDefs[6];
153 logDef.setLogName("Character_Select");
154 logDef.setLogText("A character has been selected to play");
156 logDef.getParams().resize(3);
157 logDef.getListParams().resize(0);
160 logDef.getParams()[0].setName("userId");
161 logDef.getParams()[0].setType(LGS::TSupportedParamType::spt_uint32);
162 logDef.getParams()[0].setList(false);
164 logDef.getParams()[1].setName("charId");
165 logDef.getParams()[1].setType(LGS::TSupportedParamType::spt_entityId);
166 logDef.getParams()[1].setList(false);
168 logDef.getParams()[2].setName("charName");
169 logDef.getParams()[2].setType(LGS::TSupportedParamType::spt_string);
170 logDef.getParams()[2].setList(false);
175 LGS::TLogDefinition &logDef = _LogDefs[7];
179 logDef.setLogName("Character_LevelUp");
180 logDef.setLogText("A character has gained a level");
182 logDef.getParams().resize(3);
183 logDef.getListParams().resize(0);
186 logDef.getParams()[0].setName("charId");
187 logDef.getParams()[0].setType(LGS::TSupportedParamType::spt_entityId);
188 logDef.getParams()[0].setList(false);
190 logDef.getParams()[1].setName("skillName");
191 logDef.getParams()[1].setType(LGS::TSupportedParamType::spt_string);
192 logDef.getParams()[1].setList(false);
194 logDef.getParams()[2].setName("level");
195 logDef.getParams()[2].setType(LGS::TSupportedParamType::spt_uint32);
196 logDef.getParams()[2].setList(false);
201 LGS::TLogDefinition &logDef = _LogDefs[8];
205 logDef.setLogName("Character_UpdateSP");
206 logDef.setLogText("A character Skill Point is updated");
208 logDef.getParams().resize(4);
209 logDef.getListParams().resize(0);
212 logDef.getParams()[0].setName("charId");
213 logDef.getParams()[0].setType(LGS::TSupportedParamType::spt_entityId);
215 logDef.getParams()[1].setName("spName");
216 logDef.getParams()[1].setType(LGS::TSupportedParamType::spt_string);
217 logDef.getParams()[1].setList(false);
219 logDef.getParams()[2].setName("spBefore");
220 logDef.getParams()[2].setType(LGS::TSupportedParamType::spt_float);
221 logDef.getParams()[2].setList(false);
223 logDef.getParams()[3].setName("spAfter");
224 logDef.getParams()[3].setType(LGS::TSupportedParamType::spt_float);
225 logDef.getParams()[3].setList(false);
230 LGS::TLogDefinition &logDef = _LogDefs[9];
234 logDef.setLogName("Character_LearnPhrase");
235 logDef.setLogText("A character learn a new rolemaster phrase");
237 logDef.getParams().resize(2);
238 logDef.getListParams().resize(0);
241 logDef.getParams()[0].setName("charId");
242 logDef.getParams()[0].setType(LGS::TSupportedParamType::spt_entityId);
244 logDef.getParams()[1].setName("phraseId");
245 logDef.getParams()[1].setType(LGS::TSupportedParamType::spt_sheetId);
246 logDef.getParams()[1].setList(false);
251 LGS::TLogDefinition &logDef = _LogDefs[10];
255 logDef.setLogName("Character_AddKnownBrick");
256 logDef.setLogText("A character receive a new brick");
258 logDef.getParams().resize(2);
259 logDef.getListParams().resize(0);
262 logDef.getParams()[0].setName("charId");
263 logDef.getParams()[0].setType(LGS::TSupportedParamType::spt_entityId);
265 logDef.getParams()[1].setName("brickId");
266 logDef.getParams()[1].setType(LGS::TSupportedParamType::spt_sheetId);
267 logDef.getParams()[1].setList(false);
272 // Register the log definitions
273 LGS::ILoggerServiceClient::addLogDefinitions(_LogDefs);
276 // Context var stack accessor
278 bool getContextVar_charId (NLMISC::CEntityId &value)
280 if (_charId.empty())
281 return false;
283 value = _charId.back();
284 return true;
287 void pushContextVar_charId (const NLMISC::CEntityId &value)
289 _charId.push_back(value);
291 void popContextVar_charId ()
293 _charId.pop_back();
297 void pushNoContext()
299 ++_NoContextCount;
301 void popNoContext()
303 nlassert(_NoContextCount > 0);
304 --_NoContextCount;
307 uint32 getNoContextCount()
309 return _NoContextCount;
313 // Instantiate the descriptor class
314 CCharacterDesc CharacterDesc;
318 const std::string TLogContext_Character_BuyRolemasterPhrase::_ContextName("Character_BuyRolemasterPhrase");
319 /// The constructor push a log context in the logger system
320 TLogContext_Character_BuyRolemasterPhrase::TLogContext_Character_BuyRolemasterPhrase(const NLMISC::CEntityId &charId)
322 if (LGS::ILoggerServiceClient::isInitialized())
323 LGS::ILoggerServiceClient::getInstance()->pushLogContext(_ContextName);
325 // stack the context param in the context class object
326 CharacterDesc.pushContextVar_charId(charId);
330 /// The destructor pop a context in the logger system
331 TLogContext_Character_BuyRolemasterPhrase::~TLogContext_Character_BuyRolemasterPhrase()
333 if (LGS::ILoggerServiceClient::isInitialized())
334 LGS::ILoggerServiceClient::getInstance()->popLogContext(_ContextName);
336 // pop the context param in the context class object
337 CharacterDesc.popContextVar_charId();
341 const std::string TLogContext_Character_AdminCommand::_ContextName("Character_AdminCommand");
342 /// The constructor push a log context in the logger system
343 TLogContext_Character_AdminCommand::TLogContext_Character_AdminCommand(const NLMISC::CEntityId &charId)
345 if (LGS::ILoggerServiceClient::isInitialized())
346 LGS::ILoggerServiceClient::getInstance()->pushLogContext(_ContextName);
348 // stack the context param in the context class object
349 CharacterDesc.pushContextVar_charId(charId);
353 /// The destructor pop a context in the logger system
354 TLogContext_Character_AdminCommand::~TLogContext_Character_AdminCommand()
356 if (LGS::ILoggerServiceClient::isInitialized())
357 LGS::ILoggerServiceClient::getInstance()->popLogContext(_ContextName);
359 // pop the context param in the context class object
360 CharacterDesc.popContextVar_charId();
364 const std::string TLogContext_Character_SkillProgress::_ContextName("Character_SkillProgress");
365 /// The constructor push a log context in the logger system
366 TLogContext_Character_SkillProgress::TLogContext_Character_SkillProgress(const NLMISC::CEntityId &charId)
368 if (LGS::ILoggerServiceClient::isInitialized())
369 LGS::ILoggerServiceClient::getInstance()->pushLogContext(_ContextName);
371 // stack the context param in the context class object
372 CharacterDesc.pushContextVar_charId(charId);
376 /// The destructor pop a context in the logger system
377 TLogContext_Character_SkillProgress::~TLogContext_Character_SkillProgress()
379 if (LGS::ILoggerServiceClient::isInitialized())
380 LGS::ILoggerServiceClient::getInstance()->popLogContext(_ContextName);
382 // pop the context param in the context class object
383 CharacterDesc.popContextVar_charId();
387 const std::string TLogContext_Character_MissionRecvXp::_ContextName("Character_MissionRecvXp");
388 /// The constructor push a log context in the logger system
389 TLogContext_Character_MissionRecvXp::TLogContext_Character_MissionRecvXp(const NLMISC::CEntityId &charId)
391 if (LGS::ILoggerServiceClient::isInitialized())
392 LGS::ILoggerServiceClient::getInstance()->pushLogContext(_ContextName);
394 // stack the context param in the context class object
395 CharacterDesc.pushContextVar_charId(charId);
399 /// The destructor pop a context in the logger system
400 TLogContext_Character_MissionRecvXp::~TLogContext_Character_MissionRecvXp()
402 if (LGS::ILoggerServiceClient::isInitialized())
403 LGS::ILoggerServiceClient::getInstance()->popLogContext(_ContextName);
405 // pop the context param in the context class object
406 CharacterDesc.popContextVar_charId();
411 /// No context context. Use this to disable any contextual log underneath
412 TLogNoContext_Character::TLogNoContext_Character()
414 CharacterDesc.pushNoContext();
417 TLogNoContext_Character::~TLogNoContext_Character()
419 CharacterDesc.popNoContext();
424 void _log_Character_Create(uint32 userId, const NLMISC::CEntityId &charId, const std::string &charName, const char *_filename_, uint _lineNo_)
426 static LGS::TLogInfo logInfo;
427 static bool init = false;
428 if (!init)
430 logInfo.setLogName("Character_Create");
431 logInfo.getParams().resize(3);
432 logInfo.getListParams().resize(0);
436 logInfo.getParams()[0] = LGS::TParamValue(userId);
438 logInfo.getParams()[1] = LGS::TParamValue(charId);
440 logInfo.getParams()[2] = LGS::TParamValue(charName);
443 logInfo.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
445 if (LGS::ILoggerServiceClient::isInitialized())
446 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo);
449 void _log_Character_Delete(uint32 userId, const NLMISC::CEntityId &charId, const std::string &charName, const char *_filename_, uint _lineNo_)
451 static LGS::TLogInfo logInfo;
452 static bool init = false;
453 if (!init)
455 logInfo.setLogName("Character_Delete");
456 logInfo.getParams().resize(3);
457 logInfo.getListParams().resize(0);
461 logInfo.getParams()[0] = LGS::TParamValue(userId);
463 logInfo.getParams()[1] = LGS::TParamValue(charId);
465 logInfo.getParams()[2] = LGS::TParamValue(charName);
468 logInfo.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
470 if (LGS::ILoggerServiceClient::isInitialized())
471 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo);
474 void _log_Character_Select(uint32 userId, const NLMISC::CEntityId &charId, const std::string &charName, const char *_filename_, uint _lineNo_)
476 static LGS::TLogInfo logInfo;
477 static bool init = false;
478 if (!init)
480 logInfo.setLogName("Character_Select");
481 logInfo.getParams().resize(3);
482 logInfo.getListParams().resize(0);
486 logInfo.getParams()[0] = LGS::TParamValue(userId);
488 logInfo.getParams()[1] = LGS::TParamValue(charId);
490 logInfo.getParams()[2] = LGS::TParamValue(charName);
493 logInfo.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
495 if (LGS::ILoggerServiceClient::isInitialized())
496 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo);
499 void _log_Character_LevelUp(const NLMISC::CEntityId &charId, const std::string &skillName, uint32 level, const char *_filename_, uint _lineNo_)
501 static LGS::TLogInfo logInfo;
502 static bool init = false;
503 if (!init)
505 logInfo.setLogName("Character_LevelUp");
506 logInfo.getParams().resize(3);
507 logInfo.getListParams().resize(0);
511 logInfo.getParams()[0] = LGS::TParamValue(charId);
513 logInfo.getParams()[1] = LGS::TParamValue(skillName);
515 logInfo.getParams()[2] = LGS::TParamValue(level);
518 logInfo.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
520 if (LGS::ILoggerServiceClient::isInitialized())
521 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo);
524 void _log_Character_UpdateSP(const std::string &spName, float spBefore, float spAfter, const char *_filename_, uint _lineNo_)
526 static LGS::TLogInfo logInfo;
527 static bool init = false;
528 if (!init)
530 logInfo.setLogName("Character_UpdateSP");
531 logInfo.getParams().resize(4);
532 logInfo.getListParams().resize(0);
536 // Context parameter
537 NLMISC::CEntityId charId;
538 if (!CharacterDesc.getContextVar_charId(charId))
540 // If this bomb is thrown, you need to add a log context (or otherwise a 'noContext').
541 STOP_IF(CharacterDesc.getNoContextCount() == 0, _filename_<<"("<<_lineNo_<<") : Missing log context for log 'Character'");
542 return;
546 logInfo.getParams()[0] = LGS::TParamValue(charId);
548 logInfo.getParams()[1] = LGS::TParamValue(spName);
550 logInfo.getParams()[2] = LGS::TParamValue(spBefore);
552 logInfo.getParams()[3] = LGS::TParamValue(spAfter);
555 logInfo.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
557 if (LGS::ILoggerServiceClient::isInitialized())
558 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo);
561 void _log_Character_LearnPhrase(const NLMISC::CSheetId &phraseId, const char *_filename_, uint _lineNo_)
563 static LGS::TLogInfo logInfo;
564 static bool init = false;
565 if (!init)
567 logInfo.setLogName("Character_LearnPhrase");
568 logInfo.getParams().resize(2);
569 logInfo.getListParams().resize(0);
573 // Context parameter
574 NLMISC::CEntityId charId;
575 if (!CharacterDesc.getContextVar_charId(charId))
577 // If this bomb is thrown, you need to add a log context (or otherwise a 'noContext').
578 STOP_IF(CharacterDesc.getNoContextCount() == 0, _filename_<<"("<<_lineNo_<<") : Missing log context for log 'Character'");
579 return;
583 logInfo.getParams()[0] = LGS::TParamValue(charId);
585 logInfo.getParams()[1] = LGS::TParamValue(phraseId);
588 logInfo.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
590 if (LGS::ILoggerServiceClient::isInitialized())
591 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo);
594 void _log_Character_AddKnownBrick(const NLMISC::CSheetId &brickId, const char *_filename_, uint _lineNo_)
596 static LGS::TLogInfo logInfo;
597 static bool init = false;
598 if (!init)
600 logInfo.setLogName("Character_AddKnownBrick");
601 logInfo.getParams().resize(2);
602 logInfo.getListParams().resize(0);
606 // Context parameter
607 NLMISC::CEntityId charId;
608 if (!CharacterDesc.getContextVar_charId(charId))
610 // If this bomb is thrown, you need to add a log context (or otherwise a 'noContext').
611 STOP_IF(CharacterDesc.getNoContextCount() == 0, _filename_<<"("<<_lineNo_<<") : Missing log context for log 'Character'");
612 return;
616 logInfo.getParams()[0] = LGS::TParamValue(charId);
618 logInfo.getParams()[1] = LGS::TParamValue(brickId);
621 logInfo.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
623 if (LGS::ILoggerServiceClient::isInitialized())
624 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo);
627 void _log_Character_RemoveKnownBrick(const NLMISC::CSheetId &brickId, const char *_filename_, uint _lineNo_)
629 static LGS::TLogInfo logInfo;
630 static bool init = false;
631 if (!init)
633 logInfo.setLogName("Character_RemoveKnownBrick");
634 logInfo.getParams().resize(2);
635 logInfo.getListParams().resize(0);
639 // Context parameter
640 NLMISC::CEntityId charId;
641 if (!CharacterDesc.getContextVar_charId(charId))
643 // If this bomb is thrown, you need to add a log context (or otherwise a 'noContext').
644 STOP_IF(CharacterDesc.getNoContextCount() == 0, _filename_<<"("<<_lineNo_<<") : Missing log context for log 'Character'");
645 return;
649 logInfo.getParams()[0] = LGS::TParamValue(charId);
651 logInfo.getParams()[1] = LGS::TParamValue(brickId);
654 logInfo.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
656 if (LGS::ILoggerServiceClient::isInitialized())
657 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo);