Add output levels --info and --trace (--verbose is now more verbose)

This commit is contained in:
Perttu Ahola 2012-03-22 14:10:24 +02:00
parent 2671b9af1b
commit c13691a8e6
5 changed files with 34 additions and 9 deletions

View File

@ -61,9 +61,15 @@ Run dedicated server
\-\-speedtests \-\-speedtests
Run speed tests Run speed tests
.TP .TP
\-\-verbose \-\-info
Print more information to console Print more information to console
.TP .TP
\-\-verbose
Print even more information to console
.TP
\-\-trace
Print enormous amounts of information to console
.TP
\-\-world <value> \-\-world <value>
Set world path Set world path

View File

@ -40,9 +40,15 @@ Same as --world (deprecated)
\-\-port <value> \-\-port <value>
Set network port (UDP) to use Set network port (UDP) to use
.TP .TP
\-\-verbose \-\-info
Print more information to console Print more information to console
.TP .TP
\-\-verbose
Print even more information to console
.TP
\-\-trace
Print enormous amounts of information to console
.TP
\-\-world <value> \-\-world <value>
Set world path Set world path

View File

@ -90,8 +90,6 @@ Profiler *g_profiler = &main_profiler;
// Connection // Connection
std::ostream *dout_con_ptr = &dummyout; std::ostream *dout_con_ptr = &dummyout;
std::ostream *derr_con_ptr = &verbosestream; std::ostream *derr_con_ptr = &verbosestream;
//std::ostream *dout_con_ptr = &infostream;
//std::ostream *derr_con_ptr = &errorstream;
// Server // Server
std::ostream *dout_server_ptr = &infostream; std::ostream *dout_server_ptr = &infostream;
@ -779,8 +777,12 @@ int main(int argc, char *argv[])
"Same as --world (deprecated)")); "Same as --world (deprecated)"));
allowed_options.insert("world", ValueSpec(VALUETYPE_STRING, allowed_options.insert("world", ValueSpec(VALUETYPE_STRING,
"Set world path (implies local game)")); "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")); "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, allowed_options.insert("logfile", ValueSpec(VALUETYPE_STRING,
"Set logfile path ('' = no logging)")); "Set logfile path ('' = no logging)"));
allowed_options.insert("gameid", ValueSpec(VALUETYPE_STRING, allowed_options.insert("gameid", ValueSpec(VALUETYPE_STRING,
@ -833,9 +835,19 @@ int main(int argc, char *argv[])
Low-level initialization 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 // 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); 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(); porting::signal_handler_init();
bool &kill = *porting::signal_handler_killstatus(); bool &kill = *porting::signal_handler_killstatus();

View File

@ -52,9 +52,8 @@ typedef int socket_t;
#include <errno.h> #include <errno.h>
#include "utility.h" #include "utility.h"
// Debug printing options bool socket_enable_debug_output = false;
// Set to 1 for debug output #define DP socket_enable_debug_output
#define DP 0
// This is prepended to everything printed here // This is prepended to everything printed here
#define DPS "" #define DPS ""

View File

@ -23,6 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <ostream> #include <ostream>
#include "exceptions.h" #include "exceptions.h"
extern bool socket_enable_debug_output;
class SocketException : public BaseException class SocketException : public BaseException
{ {
public: public: