From 395a3e70e9a080141662d0be11f2ef09413b3c2f Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 6 Sep 2020 14:57:58 +0100 Subject: [PATCH] Logging: use new MANDATORY_INFO level. Requires corresponding SG commit. --- src/FDM/fdm_shell.cxx | 7 +++---- src/Main/globals.cxx | 4 ++-- src/Main/main.cxx | 4 ++-- src/Scripting/NasalSys.cxx | 15 ++++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/FDM/fdm_shell.cxx b/src/FDM/fdm_shell.cxx index b51806a30..b008694e9 100644 --- a/src/FDM/fdm_shell.cxx +++ b/src/FDM/fdm_shell.cxx @@ -107,11 +107,10 @@ void FDMShell::postinit() SG_LOG(SG_FLIGHT, SG_ALERT, "Failed to save initial FDM property state"); } - _ai_mgr = dynamic_cast(globals->get_subsystem("ai-model")); - if (_ai_mgr) - SG_LOG(SG_FLIGHT, SG_INFO, "FDM connection to the AI manager: SUCCESS"); - else + _ai_mgr = globals->get_subsystem(); + if (!_ai_mgr) { SG_LOG(SG_FLIGHT, SG_DEV_ALERT, "FDM connection to the AI manager: FAILED"); + } } void FDMShell::shutdown() diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 16a4812dc..650ff6f23 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -459,7 +459,7 @@ void FGGlobals::set_terrasync_dir(const SGPath &path) { if (terrasync_dir.realpath() != SGPath(fgGetString("/sim/terrasync/scenery-dir")).realpath()) { // if they don't match, /sim/terrasync/scenery-dir has been set by something else - SG_LOG(SG_GENERAL, SG_ALERT, "/sim/terrasync/scenery-dir is no longer stored across runs: if you wish to keep using a non-standard Terrasync directory, use --terrasync-dir or the launcher's settings"); + SG_LOG(SG_GENERAL, SG_WARN, "/sim/terrasync/scenery-dir is no longer stored across runs: if you wish to keep using a non-standard Terrasync directory, use --terrasync-dir or the launcher's settings"); } SGPath abspath(path.realpath()); terrasync_dir = abspath; @@ -494,7 +494,7 @@ void FGGlobals::append_aircraft_path(const SGPath& path) { SGPath dirPath(path); if (!dirPath.exists()) { - SG_LOG(SG_GENERAL, SG_ALERT, "aircraft path not found:" << path); + SG_LOG(SG_GENERAL, SG_WARN, "aircraft path not found:" << path); return; } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 48e4a5e73..9e72e99bf 100755 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -447,7 +447,7 @@ void fgInitSecureMode() { bool secureMode = true; if (Options::sharedInstance()->isOptionSet("allow-nasal-from-sockets")) { - SG_LOG(SG_GENERAL, SG_ALERT, "\n!! Network connections allowed to use Nasal !!\n" + SG_LOG(SG_GENERAL, SG_MANDATORY_INFO, "\n!! Network connections allowed to use Nasal !!\n" "Network connections will be allowed full access to the simulator \n" "including running arbitrary scripts. Ensure you have adequate security\n" "(such as a firewall which blocks external connections).\n"); @@ -575,7 +575,7 @@ int fgMainInit( int argc, char **argv ) // show this message early, if we can auto r = flightgear::showLockFileDialog(); if (r == flightgear::LockFileReset) { - SG_LOG( SG_GENERAL, SG_ALERT, "Deleting lock file at user request"); + SG_LOG( SG_GENERAL, SG_MANDATORY_INFO, "Deleting lock file at user request"); fgDeleteLockFile(); fgSetBool("/sim/fghome-readonly", false); } else if (r == flightgear::LockFileQuit) { diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index b6eb6f7f5..53f1e0a33 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -520,8 +520,9 @@ struct SimNasalLogFileLine : SGPropertyChangeListener bool SimNasalLogFileLine::_file_line = false; // print() extension function. Concatenates and prints its arguments -// to the FlightGear log. Uses the highest log level (SG_ALERT), to -// make sure it appears. Is there better way to do this? +// to the FlightGear log. Uses the mandatory log level (SG_MANDATORY_INFO), to +// make sure it appears. Users should be converted to use logprint() instead, +// and specify a level explicitly. static naRef f_print(naContext c, naRef me, int argc, naRef* args) { static SimNasalLogFileLine snlfl; @@ -535,7 +536,7 @@ static naRef f_print(naContext c, naRef me, int argc, naRef* args) if (snlfl._file_line) { /* Copy what SG_LOG() does, but use nasal file:line instead of our own __FILE__ and __LINE__. */ - if (sglog().would_log(SG_NASAL, SG_ALERT)) { + if (sglog().would_log(SG_NASAL, SG_MANDATORY_INFO)) { int frame = 0; const char* file = naStr_data(naGetSourceFile(c, 0)); if (simgear::strutils::ends_with( file, "/globals.nas")) { @@ -547,11 +548,10 @@ static naRef f_print(naContext c, naRef me, int argc, naRef* args) file = naStr_data(naGetSourceFile(c, frame)); } int line = naGetLine(c, frame); - sglog().logCopyingFilename(SG_NASAL, SG_ALERT, file, line, buf); + sglog().logCopyingFilename(SG_NASAL, SG_MANDATORY_INFO, file, line, buf); } - } - else { - SG_LOG(SG_NASAL, SG_ALERT, buf); + } else { + SG_LOG(SG_NASAL, SG_MANDATORY_INFO, buf); } return naNum(buf.length()); } @@ -1057,6 +1057,7 @@ void FGNasalSys::initLogLevelConstants() hashset(_globals, "LOG_ALERT", naNum(SG_ALERT)); hashset(_globals, "DEV_WARN", naNum(SG_DEV_WARN)); hashset(_globals, "DEV_ALERT", naNum(SG_DEV_ALERT)); + hashset(_globals, "MANDATORY_INFO", naNum(SG_MANDATORY_INFO)); } void FGNasalSys::setCmdArg(SGPropertyNode* aNode)