summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorkwolekr <mirrorisim@gmail.com>2013-02-08 21:52:23 -0500
committerkwolekr <mirrorisim@gmail.com>2013-02-21 22:35:04 -0500
commit7f240aea1e55b0714e80ef6ab7172b58b0729f75 (patch)
tree1a4b9919ef70b219bca4f135b110ed21293a6ea6 /src/main.cpp
parentc19fc00b044daba41fbdc3762851c6a1bae74b40 (diff)
downloadminetest-7f240aea1e55b0714e80ef6ab7172b58b0729f75.tar.gz
minetest-7f240aea1e55b0714e80ef6ab7172b58b0729f75.tar.bz2
minetest-7f240aea1e55b0714e80ef6ab7172b58b0729f75.zip
Added debug log level setting
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fd3643e60..9287ec760 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -887,22 +887,7 @@ int main(int argc, char *argv[])
fs::CreateDir(porting::path_user);
init_gettext((porting::path_share + DIR_DELIM + "locale").c_str());
-
- // Initialize debug streams
-#define DEBUGFILE "debug.txt"
-#if RUN_IN_PLACE
- std::string logfile = DEBUGFILE;
-#else
- std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;
-#endif
- if(cmd_args.exists("logfile"))
- logfile = cmd_args.get("logfile");
- if(logfile != "")
- debugstreams_init(false, logfile.c_str());
- else
- debugstreams_init(false, NULL);
- infostream<<"logfile = "<<logfile<<std::endl;
infostream<<"path_share = "<<porting::path_share<<std::endl;
infostream<<"path_user = "<<porting::path_user<<std::endl;
@@ -995,6 +980,31 @@ int main(int argc, char *argv[])
if(configpath == "")
configpath = filenames[0];
}
+
+ // Initialize debug streams
+#define DEBUGFILE "debug.txt"
+#if RUN_IN_PLACE
+ std::string logfile = DEBUGFILE;
+#else
+ std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;
+#endif
+ if(cmd_args.exists("logfile"))
+ logfile = cmd_args.get("logfile");
+
+ log_remove_output(&main_dstream_no_stderr_log_out);
+ int loglevel = g_settings->getS32("debug_log_level");
+
+ if (loglevel == 0) //no logging
+ logfile = "";
+ else if (loglevel > 0 && loglevel <= LMT_NUM_VALUES)
+ log_add_output_maxlev(&main_dstream_no_stderr_log_out, (LogMessageLevel)(loglevel - 1));
+
+ if(logfile != "")
+ debugstreams_init(false, logfile.c_str());
+ else
+ debugstreams_init(false, NULL);
+
+ infostream<<"logfile = "<<logfile<<std::endl;
// Initialize random seed
srand(time(0));