]> git.mxchange.org Git - flightgear.git/commitdiff
Add runtime log level support
authorehofman <ehofman>
Sat, 22 Mar 2003 10:38:15 +0000 (10:38 +0000)
committerehofman <ehofman>
Sat, 22 Mar 2003 10:38:15 +0000 (10:38 +0000)
src/Main/fg_commands.cxx
src/Main/main.cxx
src/Main/options.cxx

index 7d99584813f64551223a33460ed2b253f3f0128d..f96948796bf11df8197996f00a0be4a2723f25a9 100644 (file)
@@ -786,6 +786,18 @@ do_presets_commit (const SGPropertyNode * arg)
     return true;
 }
 
+/**
+ * Built-in command: set log level (0 ... 7)
+ */
+static bool
+do_log_level (const SGPropertyNode * arg)
+{
+   sglog().setLogLevels( SG_ALL, (sgDebugPriority)arg->getIntValue() );
+
+   return true;
+}
+
+
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -833,6 +845,7 @@ static struct {
     { "dialog-update", do_dialog_update },
     { "dialog-apply", do_dialog_apply },
     { "presets-commit", do_presets_commit },
+    { "log-level", do_log_level },
     { 0, 0 }                   // zero-terminated
 };
 
index c1047fe3ec0472abbd71fead53d5dc145216adbd..803fc5cc44982370871c9221c9eaae7fd0f50b5c 100644 (file)
@@ -279,6 +279,7 @@ ssgSimpleState *menus;
 SGTimeStamp last_time_stamp;
 SGTimeStamp current_time_stamp;
 
+
 void fgBuildRenderStates( void ) {
     default_state = new ssgSimpleState;
     default_state->ref();
@@ -1021,6 +1022,8 @@ static void fgMainLoop( void ) {
 
     SGTime *t = globals->get_time_params();
 
+    sglog().setLogLevels( SG_ALL, (sgDebugPriority)fgGetInt("/sim/log-level") );
+
     FGLocation * acmodel_location = 0;
     if(cur_fdm_state->getACModel() != 0) {
       acmodel_location = (FGLocation *)  cur_fdm_state->getACModel()->get3DModel()->getFGLocation();
@@ -1525,7 +1528,7 @@ static bool fgMainInit( int argc, char **argv ) {
 #endif
 
     // set default log levels
-    sglog().setLogLevels( SG_ALL, SG_INFO );
+    sglog().setLogLevels( SG_ALL, SG_WARN );
 
     string version;
 #ifdef FLIGHTGEAR_VERSION
index e38d670fc83d2704666f74af414058b632c271ab..6fb18dd410b444e22f5c899bb10d8b9c85498823 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <simgear/compiler.h>
 #include <simgear/misc/exception.hxx>
+#include <simgear/debug/logstream.hxx>
 
 #include <math.h>              // rint()
 #include <stdio.h>
@@ -179,6 +180,8 @@ fgSetDefaults ()
 #else
     fgSetString("/sim/startup/browser-app", "webrun.bat");
 #endif
+    fgSetInt("/sim/log-level", SG_WARN);
+
                                // Features
     fgSetBool("/sim/hud/visibility", false);
     fgSetBool("/sim/panel/visibility", true);
@@ -928,6 +931,13 @@ fgOptTraceWrite( const char *arg )
     return FG_OPTIONS_OK;
 }
 
+static int
+fgOptDebugLevel( const char *arg )
+{
+    fgSetInt( "/sim/log-level", atoi( arg ) );
+    return FG_OPTIONS_OK;
+}
+
 static int
 fgOptViewOffset( const char *arg )
 {
@@ -1152,6 +1162,7 @@ struct OptionDesc {
 #endif
     {"trace-read",                   true,  OPTION_FUNC,   "", false, "", fgOptTraceRead },
     {"trace-write",                  true,  OPTION_FUNC,   "", false, "", fgOptTraceWrite },
+    {"log-level",                  true,  OPTION_FUNC,   "", false, "", fgOptDebugLevel },
     {"view-offset",                  true,  OPTION_FUNC,   "", false, "", fgOptViewOffset },
     {"visibility",                   true,  OPTION_DOUBLE, "/environment/visibility-m", false, "", 0 },
     {"visibility-miles",             true,  OPTION_FUNC,   "", false, "", fgOptVisibilityMiles },
@@ -1647,6 +1658,9 @@ parse_option (const string& arg)
        SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
        fgGetNode(name.c_str(), true)
          ->setAttribute(SGPropertyNode::TRACE_WRITE, true);
+    } else if ( arg.find("--log-level=") == 0) {
+        int level = atoi(arg.substr(14));
+        sglog().setLogLevels( SG_ALL, level );
     } else if ( arg.find( "--view-offset=" ) == 0 ) {
         // $$$ begin - added VS Renganathan, 14 Oct 2K
         // for multi-window outside window imagery