1
0
Fork 0

Add runtime log level support

This commit is contained in:
ehofman 2003-03-22 10:38:15 +00:00
parent d2583bb172
commit 0782e877a9
3 changed files with 31 additions and 1 deletions

View 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;
}
////////////////////////////////////////////////////////////////////////
@ -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
};

View 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

View 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