diff --git a/doc/minetest.6 b/doc/minetest.6 index 2a39b870d01a48d30df0d15dcfa6985741cedf5b..0d6433f29d8430771e6742962cc7ce52682f75a1 100644 --- a/doc/minetest.6 +++ b/doc/minetest.6 @@ -61,9 +61,15 @@ Run dedicated server \-\-speedtests Run speed tests .TP -\-\-verbose +\-\-info Print more information to console .TP +\-\-verbose +Print even more information to console +.TP +\-\-trace +Print enormous amounts of information to console +.TP \-\-world <value> Set world path diff --git a/doc/minetestserver.6 b/doc/minetestserver.6 index dffe0fc8ebeafc43abb8e22f42c04859058383ea..81203954dfad883a51dc80e83905556ad4064887 100644 --- a/doc/minetestserver.6 +++ b/doc/minetestserver.6 @@ -40,9 +40,15 @@ Same as --world (deprecated) \-\-port <value> Set network port (UDP) to use .TP -\-\-verbose +\-\-info Print more information to console .TP +\-\-verbose +Print even more information to console +.TP +\-\-trace +Print enormous amounts of information to console +.TP \-\-world <value> Set world path diff --git a/src/main.cpp b/src/main.cpp index 75ff569aa4ca16968272fccf55979f9b0dfe29cf..fe1bcd45024d500f125900f1522479f3787fc8bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,8 +90,6 @@ Profiler *g_profiler = &main_profiler; // Connection std::ostream *dout_con_ptr = &dummyout; std::ostream *derr_con_ptr = &verbosestream; -//std::ostream *dout_con_ptr = &infostream; -//std::ostream *derr_con_ptr = &errorstream; // Server std::ostream *dout_server_ptr = &infostream; @@ -779,8 +777,12 @@ int main(int argc, char *argv[]) "Same as --world (deprecated)")); allowed_options.insert("world", ValueSpec(VALUETYPE_STRING, "Set world path (implies local game)")); - allowed_options.insert("verbose", ValueSpec(VALUETYPE_FLAG, + allowed_options.insert("info", ValueSpec(VALUETYPE_FLAG, "Print more information to console")); + allowed_options.insert("verbose", ValueSpec(VALUETYPE_FLAG, + "Print even more information to console")); + allowed_options.insert("trace", ValueSpec(VALUETYPE_FLAG, + "Print enormous amounts of information to log and console")); allowed_options.insert("logfile", ValueSpec(VALUETYPE_STRING, "Set logfile path ('' = no logging)")); allowed_options.insert("gameid", ValueSpec(VALUETYPE_STRING, @@ -833,9 +835,19 @@ int main(int argc, char *argv[]) Low-level initialization */ + // If trace is enabled, enable logging of certain things + if(cmd_args.getFlag("trace")){ + dstream<<"Enabling trace level debug output"<<std::endl; + dout_con_ptr = &verbosestream; + socket_enable_debug_output = true; + } // In certain cases, output info level on stderr - if(cmd_args.getFlag("verbose") || cmd_args.getFlag("speedtests")) + if(cmd_args.getFlag("info") || cmd_args.getFlag("verbose") || + cmd_args.getFlag("trace") || cmd_args.getFlag("speedtests")) log_add_output(&main_stderr_log_out, LMT_INFO); + // In certain cases, output verbose level on stderr + if(cmd_args.getFlag("verbose") || cmd_args.getFlag("trace")) + log_add_output(&main_stderr_log_out, LMT_VERBOSE); porting::signal_handler_init(); bool &kill = *porting::signal_handler_killstatus(); diff --git a/src/socket.cpp b/src/socket.cpp index ea65ffda3cca3be8360ba7e4a7a70411619a2e49..caf1895fe6037596e3d570f768868b89b48fb711 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -52,9 +52,8 @@ typedef int socket_t; #include <errno.h> #include "utility.h" -// Debug printing options -// Set to 1 for debug output -#define DP 0 +bool socket_enable_debug_output = false; +#define DP socket_enable_debug_output // This is prepended to everything printed here #define DPS "" diff --git a/src/socket.h b/src/socket.h index fe542dfcce3079f918fa6aa1a833d99c595dfb23..ac26b575c78b346a21357bf329549165400d0e4d 100644 --- a/src/socket.h +++ b/src/socket.h @@ -23,6 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <ostream> #include "exceptions.h" +extern bool socket_enable_debug_output; + class SocketException : public BaseException { public: