From d0da5d392f64c63fefde352a2a0b569317ca59cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 24 Jan 2014 23:03:48 +0100 Subject: Added per-connection comm logging in debug mode. It is meant for debugging only, so it is compiled only into debug mode. It is activated by starting the server with "/logcomm" parameter. --- src/main.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 340149e0b..68bf6683f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,6 +19,15 @@ bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so +#ifdef _DEBUG +/** If set to true, the protocols will log each player's communication to a separate logfile */ +bool g_ShouldLogComm; +#endif + + + + + /// If defined, a thorough leak finder will be used (debug MSVC only); leaks will be output to the Output window #define ENABLE_LEAK_FINDER @@ -216,12 +225,26 @@ int main( int argc, char **argv ) #ifndef _DEBUG std::signal(SIGSEGV, NonCtrlHandler); std::signal(SIGTERM, NonCtrlHandler); - std::signal(SIGINT, NonCtrlHandler); + std::signal(SIGINT, NonCtrlHandler); #endif // DEBUG: test the dumpfile creation: // *((int *)0) = 0; + // Check if comm logging is to be enabled: + #ifdef _DEBUG + for (int i = 0; i < argc; i++) + { + if ( + (_stricmp(argv[i], "/commlog") == 0) || + (_stricmp(argv[i], "/logcomm") == 0) + ) + { + g_ShouldLogComm = true; + } + } + #endif // _DEBUG + #if !defined(ANDROID_NDK) try #endif -- cgit v1.2.3 From ebcaaad63aaf854e01f63104a820dfcbd76cc80e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 24 Jan 2014 23:05:26 +0100 Subject: Fixed *nix compilation for previous commit. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 68bf6683f..902e9e43b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -236,8 +236,8 @@ int main( int argc, char **argv ) for (int i = 0; i < argc; i++) { if ( - (_stricmp(argv[i], "/commlog") == 0) || - (_stricmp(argv[i], "/logcomm") == 0) + (NoCaseCompare(argv[i], "/commlog") == 0) || + (NoCaseCompare(argv[i], "/logcomm") == 0) ) { g_ShouldLogComm = true; -- cgit v1.2.3 From ff066453b805748d6e665b3ad219a62c777e4453 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 25 Jan 2014 15:28:16 +0100 Subject: Comm logging is available in both Debug and Release modes. --- src/main.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 902e9e43b..06b344c25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,10 +19,8 @@ bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so -#ifdef _DEBUG /** If set to true, the protocols will log each player's communication to a separate logfile */ bool g_ShouldLogComm; -#endif @@ -232,7 +230,6 @@ int main( int argc, char **argv ) // *((int *)0) = 0; // Check if comm logging is to be enabled: - #ifdef _DEBUG for (int i = 0; i < argc; i++) { if ( @@ -243,7 +240,6 @@ int main( int argc, char **argv ) g_ShouldLogComm = true; } } - #endif // _DEBUG #if !defined(ANDROID_NDK) try -- cgit v1.2.3