EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AlertService.cpp
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Zhur, Captnoord
24 */
25 
26 #include "eve-server.h"
27 
28 #include "PyServiceCD.h"
29 #include "admin/AlertService.h"
30 
31 
33 
35 : PyService(mgr, "alert"),
36  m_dispatch(new Dispatcher(this)),
37  traceLogger(nullptr)
38 {
39  _SetCallDispatcher(m_dispatch);
40 
41  m_dispatch->RegisterCall("BeanCount", &AlertService::Handle_BeanCount);
42  m_dispatch->RegisterCall("BeanDelivery", &AlertService::Handle_BeanDelivery);
43  m_dispatch->RegisterCall("GroupBeanDelivery", &AlertService::Handle_GroupBeanDelivery);
44  m_dispatch->RegisterCall("SendClientStackTraceAlert", &AlertService::Handle_SendClientStackTraceAlert);
45 
46  if (sConfig.debug.StackTrace or is_log_enabled(CLIENT__STACK_TRACE))
47  traceLogger = new PyTraceLog("evemu_client_stack_trace.txt", true, true);
48 }
49 
51 {
52  delete m_dispatch;
54 }
55 
63  _log(CLIENT__WARNING, "AlertService::Handle_BeanCount(): size=%u", call.tuple->size() );
64  //call.Dump(CLIENT__CALL_DUMP);
65 
66  PyTuple *result = new PyTuple(2);
67 
68  // what we are sending back is just a static mErrorID and the command not to do anything with it.
69  if (sConfig.debug.BeanCount or sConfig.debug.IsTestServer) {
70  result->items[0] = PyStatic.NewNone();
71  } else {
72  result->items[0] = new PyInt(34135); //ErrorID
73  }
74 
75  result->items[1] = new PyInt(0); //loggingMode, 0=local, 1=DB (Capt: This isn't correct at all as it seems..)
76 
77  return (PyRep*)result;
78 }
79 
84 // note: this is a rather complicated system....
86 {
87  _log(CLIENT__WARNING, "AlertService::Handle_BeanDelivery(): size=%u", call.tuple->size() );
88  //call.Dump(CLIENT__CALL_DUMP);
89  /* Unhandled for now as we have no interest in receiving batched python stack traces
90  * nor official style debugging... Just gimme the info dude (see Handle_SendClientStackTraceAlert).
91  */
92  return PyStatic.NewNone();
93 }
94 
96 {
97  _log(CLIENT__WARNING, "AlertService::Handle_GroupBeanDelivery(): size=%u", call.tuple->size() );
98  //call.Dump(CLIENT__CALL_DUMP);
99 
100  return PyStatic.NewNone();
101 }
102 
114  _log(CLIENT__WARNING, "AlertService::Handle_SendClientStackTraceAlert(): size=%u", call.tuple->size() );
115  //call.Dump(CLIENT__CALL_DUMP);
116  // self.stacktraceLogMode[stackID[0]] = sm.ProxySvc('alert').SendClientStackTraceAlert(stackID, stackTrace, mode, nextErrorKeyHash)
117 
118  if (sConfig.debug.StackTrace or is_log_enabled(CLIENT__STACK_TRACE))
119  traceLogger->logTrace(*call.tuple);
120 
121  return PyStatic.NewNone();
122 }
a python client stack trace logger for Evemu
Definition: PyTraceLog.h:74
Base Python wire object.
Definition: PyRep.h:66
#define sConfig
A macro for easier access to the singleton.
Dispatcher *const m_dispatch
PyCallable_Make_InnerDispatcher(AlertService) AlertService
#define _log(type, fmt,...)
Definition: logsys.h:124
size_t size() const
Definition: PyRep.h:591
PyResult Handle_BeanCount(PyCallArgs &call)
virtual ~AlertService()
Dispatcher *const m_dispatch
Definition: AlertService.h:39
Python tuple.
Definition: PyRep.h:567
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
#define is_log_enabled(type)
Definition: logsys.h:78
Python integer.
Definition: PyRep.h:231
PyTraceLog * traceLogger
Definition: AlertService.h:48
#define PyStatic
Definition: PyRep.h:1209
PyResult Handle_BeanDelivery(PyCallArgs &call)
PyResult Handle_SendClientStackTraceAlert(PyCallArgs &call)
The client sends us a python stack trace, from which we could make up what we did wrong...
bool logTrace(PyTuple &tuple)
logTrace is the function what its all about.
Definition: PyTraceLog.h:133
PyResult Handle_GroupBeanDelivery(PyCallArgs &call)
PyTuple * tuple
Definition: PyCallable.h:50