@@ -887,22 +887,7 @@ int main(int argc, char *argv[])
887
887
fs::CreateDir (porting::path_user);
888
888
889
889
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 );
904
890
905
- infostream<<" logfile = " <<logfile<<std::endl;
906
891
infostream<<" path_share = " <<porting::path_share<<std::endl;
907
892
infostream<<" path_user = " <<porting::path_user<<std::endl;
908
893
@@ -995,6 +980,31 @@ int main(int argc, char *argv[])
995
980
if (configpath == " " )
996
981
configpath = filenames[0 ];
997
982
}
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;
998
1008
999
1009
// Initialize random seed
1000
1010
srand (time (0 ));
0 commit comments