1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "game_share/utils.h"
19 #include "log_player_gen.h"
22 #include "logger_service_itf.h"
23 #include "logger_service_client.h"
25 // A function fo force linking of this code module
26 void forceLink_Player(){}
33 friend class CLoggerClient
;
35 /// The list of log definition for this log class
36 std::vector
<LGS::TLogDefinition
> _LogDefs
;
38 /// Stack of context variable
41 /// Counter of 'no context' object stacked.
42 uint32 _NoContextCount
;
52 LGS::TLogDefinition
&logDef
= _LogDefs
[0];
56 logDef
.setLogName("Player_Connect");
57 logDef
.setLogText("The player has connected");
59 logDef
.getParams().resize(2);
60 logDef
.getListParams().resize(0);
63 logDef
.getParams()[0].setName("userId");
64 logDef
.getParams()[0].setType(LGS::TSupportedParamType::spt_uint32
);
65 logDef
.getParams()[0].setList(false);
67 logDef
.getParams()[1].setName("fromAddr");
68 logDef
.getParams()[1].setType(LGS::TSupportedParamType::spt_string
);
69 logDef
.getParams()[1].setList(false);
74 LGS::TLogDefinition
&logDef
= _LogDefs
[1];
78 logDef
.setLogName("Player_Disconnect");
79 logDef
.setLogText("The player has disconnected");
81 logDef
.getParams().resize(2);
82 logDef
.getListParams().resize(0);
85 logDef
.getParams()[0].setName("userId");
86 logDef
.getParams()[0].setType(LGS::TSupportedParamType::spt_uint32
);
87 logDef
.getParams()[0].setList(false);
89 logDef
.getParams()[1].setName("crashed");
90 logDef
.getParams()[1].setType(LGS::TSupportedParamType::spt_uint32
);
91 logDef
.getParams()[1].setList(false);
96 // Register the log definitions
97 LGS::ILoggerServiceClient::addLogDefinitions(_LogDefs
);
100 // Context var stack accessor
109 nlassert(_NoContextCount
> 0);
113 uint32
getNoContextCount()
115 return _NoContextCount
;
119 // Instantiate the descriptor class
120 CPlayerDesc PlayerDesc
;
125 /// No context context. Use this to disable any contextual log underneath
126 TLogNoContext_Player::TLogNoContext_Player()
128 PlayerDesc
.pushNoContext();
131 TLogNoContext_Player::~TLogNoContext_Player()
133 PlayerDesc
.popNoContext();
138 void _log_Player_Connect(uint32 userId
, const std::string
&fromAddr
, const char *_filename_
, uint _lineNo_
)
140 static LGS::TLogInfo logInfo
;
141 static bool init
= false;
144 logInfo
.setLogName("Player_Connect");
145 logInfo
.getParams().resize(2);
146 logInfo
.getListParams().resize(0);
150 logInfo
.getParams()[0] = LGS::TParamValue(userId
);
152 logInfo
.getParams()[1] = LGS::TParamValue(fromAddr
);
155 logInfo
.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
157 if (LGS::ILoggerServiceClient::isInitialized())
158 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo
);
161 void _log_Player_Disconnect(uint32 userId
, bool crashed
, const char *_filename_
, uint _lineNo_
)
163 static LGS::TLogInfo logInfo
;
164 static bool init
= false;
167 logInfo
.setLogName("Player_Disconnect");
168 logInfo
.getParams().resize(2);
169 logInfo
.getListParams().resize(0);
173 logInfo
.getParams()[0] = LGS::TParamValue(userId
);
175 logInfo
.getParams()[1] = LGS::TParamValue(crashed
);
178 logInfo
.setTimeStamp(NLMISC::CTime::getSecondsSince1970());
180 if (LGS::ILoggerServiceClient::isInitialized())
181 LGS::ILoggerServiceClient::getInstance()->sendLog(logInfo
);