Skip to content

Commit 7f240ae

Browse files
author
kwolekr
committedFeb 22, 2013
Added debug log level setting
1 parent c19fc00 commit 7f240ae

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed
 

‎src/defaultsettings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void set_default_settings(Settings *settings)
183183
settings->setDefault("congestion_control_max_rate", "400");
184184
settings->setDefault("congestion_control_min_rate", "10");
185185
settings->setDefault("remote_media", "");
186-
186+
settings->setDefault("debug_log_level", "0");
187187
// physics stuff
188188
settings->setDefault("movement_acceleration_default", "3");
189189
settings->setDefault("movement_acceleration_air", "2");

‎src/main.cpp

+25-15
Original file line numberDiff line numberDiff line change
@@ -887,22 +887,7 @@ int main(int argc, char *argv[])
887887
fs::CreateDir(porting::path_user);
888888

889889
init_gettext((porting::path_share + DIR_DELIM + "locale").c_str());
890-
891-
// Initialize debug streams
892-
#define DEBUGFILE "debug.txt"
893-
#if RUN_IN_PLACE
894-
std::string logfile = DEBUGFILE;
895-
#else
896-
std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;
897-
#endif
898-
if(cmd_args.exists("logfile"))
899-
logfile = cmd_args.get("logfile");
900-
if(logfile != "")
901-
debugstreams_init(false, logfile.c_str());
902-
else
903-
debugstreams_init(false, NULL);
904890

905-
infostream<<"logfile = "<<logfile<<std::endl;
906891
infostream<<"path_share = "<<porting::path_share<<std::endl;
907892
infostream<<"path_user = "<<porting::path_user<<std::endl;
908893

@@ -995,6 +980,31 @@ int main(int argc, char *argv[])
995980
if(configpath == "")
996981
configpath = filenames[0];
997982
}
983+
984+
// Initialize debug streams
985+
#define DEBUGFILE "debug.txt"
986+
#if RUN_IN_PLACE
987+
std::string logfile = DEBUGFILE;
988+
#else
989+
std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;
990+
#endif
991+
if(cmd_args.exists("logfile"))
992+
logfile = cmd_args.get("logfile");
993+
994+
log_remove_output(&main_dstream_no_stderr_log_out);
995+
int loglevel = g_settings->getS32("debug_log_level");
996+
997+
if (loglevel == 0) //no logging
998+
logfile = "";
999+
else if (loglevel > 0 && loglevel <= LMT_NUM_VALUES)
1000+
log_add_output_maxlev(&main_dstream_no_stderr_log_out, (LogMessageLevel)(loglevel - 1));
1001+
1002+
if(logfile != "")
1003+
debugstreams_init(false, logfile.c_str());
1004+
else
1005+
debugstreams_init(false, NULL);
1006+
1007+
infostream<<"logfile = "<<logfile<<std::endl;
9981008

9991009
// Initialize random seed
10001010
srand(time(0));

0 commit comments

Comments
 (0)
Please sign in to comment.