Add runtime log level support
This commit is contained in:
parent
d2583bb172
commit
0782e877a9
3 changed files with 31 additions and 1 deletions
|
@ -786,6 +786,18 @@ do_presets_commit (const SGPropertyNode * arg)
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -833,6 +845,7 @@ static struct {
|
||||||
{ "dialog-update", do_dialog_update },
|
{ "dialog-update", do_dialog_update },
|
||||||
{ "dialog-apply", do_dialog_apply },
|
{ "dialog-apply", do_dialog_apply },
|
||||||
{ "presets-commit", do_presets_commit },
|
{ "presets-commit", do_presets_commit },
|
||||||
|
{ "log-level", do_log_level },
|
||||||
{ 0, 0 } // zero-terminated
|
{ 0, 0 } // zero-terminated
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,7 @@ ssgSimpleState *menus;
|
||||||
SGTimeStamp last_time_stamp;
|
SGTimeStamp last_time_stamp;
|
||||||
SGTimeStamp current_time_stamp;
|
SGTimeStamp current_time_stamp;
|
||||||
|
|
||||||
|
|
||||||
void fgBuildRenderStates( void ) {
|
void fgBuildRenderStates( void ) {
|
||||||
default_state = new ssgSimpleState;
|
default_state = new ssgSimpleState;
|
||||||
default_state->ref();
|
default_state->ref();
|
||||||
|
@ -1021,6 +1022,8 @@ static void fgMainLoop( void ) {
|
||||||
|
|
||||||
SGTime *t = globals->get_time_params();
|
SGTime *t = globals->get_time_params();
|
||||||
|
|
||||||
|
sglog().setLogLevels( SG_ALL, (sgDebugPriority)fgGetInt("/sim/log-level") );
|
||||||
|
|
||||||
FGLocation * acmodel_location = 0;
|
FGLocation * acmodel_location = 0;
|
||||||
if(cur_fdm_state->getACModel() != 0) {
|
if(cur_fdm_state->getACModel() != 0) {
|
||||||
acmodel_location = (FGLocation *) cur_fdm_state->getACModel()->get3DModel()->getFGLocation();
|
acmodel_location = (FGLocation *) cur_fdm_state->getACModel()->get3DModel()->getFGLocation();
|
||||||
|
@ -1525,7 +1528,7 @@ static bool fgMainInit( int argc, char **argv ) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// set default log levels
|
// set default log levels
|
||||||
sglog().setLogLevels( SG_ALL, SG_INFO );
|
sglog().setLogLevels( SG_ALL, SG_WARN );
|
||||||
|
|
||||||
string version;
|
string version;
|
||||||
#ifdef FLIGHTGEAR_VERSION
|
#ifdef FLIGHTGEAR_VERSION
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/misc/exception.hxx>
|
#include <simgear/misc/exception.hxx>
|
||||||
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
|
||||||
#include <math.h> // rint()
|
#include <math.h> // rint()
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -179,6 +180,8 @@ fgSetDefaults ()
|
||||||
#else
|
#else
|
||||||
fgSetString("/sim/startup/browser-app", "webrun.bat");
|
fgSetString("/sim/startup/browser-app", "webrun.bat");
|
||||||
#endif
|
#endif
|
||||||
|
fgSetInt("/sim/log-level", SG_WARN);
|
||||||
|
|
||||||
// Features
|
// Features
|
||||||
fgSetBool("/sim/hud/visibility", false);
|
fgSetBool("/sim/hud/visibility", false);
|
||||||
fgSetBool("/sim/panel/visibility", true);
|
fgSetBool("/sim/panel/visibility", true);
|
||||||
|
@ -928,6 +931,13 @@ fgOptTraceWrite( const char *arg )
|
||||||
return FG_OPTIONS_OK;
|
return FG_OPTIONS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
fgOptDebugLevel( const char *arg )
|
||||||
|
{
|
||||||
|
fgSetInt( "/sim/log-level", atoi( arg ) );
|
||||||
|
return FG_OPTIONS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fgOptViewOffset( const char *arg )
|
fgOptViewOffset( const char *arg )
|
||||||
{
|
{
|
||||||
|
@ -1152,6 +1162,7 @@ struct OptionDesc {
|
||||||
#endif
|
#endif
|
||||||
{"trace-read", true, OPTION_FUNC, "", false, "", fgOptTraceRead },
|
{"trace-read", true, OPTION_FUNC, "", false, "", fgOptTraceRead },
|
||||||
{"trace-write", true, OPTION_FUNC, "", false, "", fgOptTraceWrite },
|
{"trace-write", true, OPTION_FUNC, "", false, "", fgOptTraceWrite },
|
||||||
|
{"log-level", true, OPTION_FUNC, "", false, "", fgOptDebugLevel },
|
||||||
{"view-offset", true, OPTION_FUNC, "", false, "", fgOptViewOffset },
|
{"view-offset", true, OPTION_FUNC, "", false, "", fgOptViewOffset },
|
||||||
{"visibility", true, OPTION_DOUBLE, "/environment/visibility-m", false, "", 0 },
|
{"visibility", true, OPTION_DOUBLE, "/environment/visibility-m", false, "", 0 },
|
||||||
{"visibility-miles", true, OPTION_FUNC, "", false, "", fgOptVisibilityMiles },
|
{"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);
|
SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
|
||||||
fgGetNode(name.c_str(), true)
|
fgGetNode(name.c_str(), true)
|
||||||
->setAttribute(SGPropertyNode::TRACE_WRITE, 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 ) {
|
} else if ( arg.find( "--view-offset=" ) == 0 ) {
|
||||||
// $$$ begin - added VS Renganathan, 14 Oct 2K
|
// $$$ begin - added VS Renganathan, 14 Oct 2K
|
||||||
// for multi-window outside window imagery
|
// for multi-window outside window imagery
|
||||||
|
|
Loading…
Reference in a new issue