Add support for verbose logging.

This commit is contained in:
dongresource 2020-08-22 19:39:13 +02:00
parent 43f2def80b
commit 35c622d8a2
5 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,6 @@
# should the server print every packet it receives?
verbose=false
# Login Server configuration # Login Server configuration
[login] [login]
# must be kept in sync with loginInfo.php # must be kept in sync with loginInfo.php

View File

@ -17,6 +17,9 @@ CNLoginServer::CNLoginServer(uint16_t p) {
} }
void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) { void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
if (settings::VERBOSE)
std::cout << "OpenFusion: received " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
switch (data->type) { switch (data->type) {
case P_CL2LS_REQ_LOGIN: { case P_CL2LS_REQ_LOGIN: {
if (data->size != sizeof(sP_CL2LS_REQ_LOGIN)) if (data->size != sizeof(sP_CL2LS_REQ_LOGIN))

View File

@ -3,6 +3,7 @@
#include "CNShardServer.hpp" #include "CNShardServer.hpp"
#include "PlayerManager.hpp" #include "PlayerManager.hpp"
#include "CNShared.hpp" #include "CNShared.hpp"
#include "settings.hpp"
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@ -17,6 +18,10 @@ CNShardServer::CNShardServer(uint16_t p) {
} }
void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) { void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
if (settings::VERBOSE)
std::cout << "OpenFusion: received " << Defines::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
if (ShardPackets.find(data->type) != ShardPackets.end()) if (ShardPackets.find(data->type) != ShardPackets.end())
ShardPackets[data->type](sock, data); ShardPackets[data->type](sock, data);
else else

View File

@ -3,6 +3,8 @@
#include "contrib/INIReader.hpp" #include "contrib/INIReader.hpp"
// defaults :) // defaults :)
bool settings::VERBOSE = false;
int settings::LOGINPORT = 8001; int settings::LOGINPORT = 8001;
bool settings::LOGINRANDCHARACTERS = false; bool settings::LOGINRANDCHARACTERS = false;
@ -30,6 +32,7 @@ void settings::init() {
return; return;
} }
VERBOSE = reader.GetBoolean("", "verbose", VERBOSE);
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT); LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
LOGINRANDCHARACTERS = reader.GetBoolean("login", "randomcharacters", LOGINRANDCHARACTERS); LOGINRANDCHARACTERS = reader.GetBoolean("login", "randomcharacters", LOGINRANDCHARACTERS);
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT); SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);

View File

@ -2,6 +2,7 @@
#define _SETT_HPP #define _SETT_HPP
namespace settings { namespace settings {
extern bool VERBOSE;
extern int LOGINPORT; extern int LOGINPORT;
extern bool LOGINRANDCHARACTERS; extern bool LOGINRANDCHARACTERS;
extern int SHARDPORT; extern int SHARDPORT;