Log-to-file level can be raised to debug/bulk
Fixes ticket: https://sourceforge.net/p/flightgear/codetickets/2100/
This commit is contained in:
parent
22ed65bbb8
commit
05e40bfde3
3 changed files with 24 additions and 15 deletions
|
@ -249,7 +249,6 @@ void initApp(int& argc, char** argv, bool doInitQSettings)
|
|||
if (!qtInitDone) {
|
||||
qtInitDone = true;
|
||||
|
||||
sglog().setLogLevels( SG_ALL, SG_INFO );
|
||||
initQtResources(); // can't be called from a namespace
|
||||
|
||||
s_argc = argc; // QApplication only stores a reference to argc,
|
||||
|
|
|
@ -194,20 +194,18 @@ setLoggingPriority (const char * p)
|
|||
{
|
||||
if (p == 0)
|
||||
return;
|
||||
|
||||
string priority = p;
|
||||
if (priority == "bulk") {
|
||||
sglog().set_log_priority(SG_BULK);
|
||||
} else if (priority == "debug") {
|
||||
sglog().set_log_priority(SG_DEBUG);
|
||||
} else if (priority.empty() || priority == "info") { // default
|
||||
if (priority.empty()) {
|
||||
sglog().set_log_priority(SG_INFO);
|
||||
} else if (priority == "warn") {
|
||||
sglog().set_log_priority(SG_WARN);
|
||||
} else if (priority == "alert") {
|
||||
sglog().set_log_priority(SG_ALERT);
|
||||
} else {
|
||||
SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging priority " << priority);
|
||||
try {
|
||||
sglog().set_log_priority(logstream::priorityFromString(priority));
|
||||
} catch (std::exception& e) {
|
||||
SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging priority: " << priority);
|
||||
}
|
||||
}
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Logging priority is " << getLoggingPriority());
|
||||
}
|
||||
|
||||
|
|
|
@ -506,8 +506,18 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
|
||||
static void logToHome()
|
||||
static void logToHome(const std::string& pri)
|
||||
{
|
||||
sgDebugPriority fileLogLevel = SG_INFO;
|
||||
// https://sourceforge.net/p/flightgear/codetickets/2100/
|
||||
if (!pri.empty()) {
|
||||
try {
|
||||
fileLogLevel = std::min(fileLogLevel, logstream::priorityFromString(pri));
|
||||
} catch (std::exception& e) {
|
||||
// let's not worry about this, and just log at INFO
|
||||
}
|
||||
}
|
||||
|
||||
SGPath logPath = globals->get_fg_home();
|
||||
logPath.append("fgfs.log");
|
||||
if (logPath.exists()) {
|
||||
|
@ -518,7 +528,8 @@ static void logToHome()
|
|||
logPath = globals->get_fg_home();
|
||||
logPath.append("fgfs.log");
|
||||
}
|
||||
sglog().logToFile(logPath, SG_ALL, SG_INFO);
|
||||
|
||||
sglog().logToFile(logPath, SG_ALL, fileLogLevel);
|
||||
}
|
||||
|
||||
// Main top level initialization
|
||||
|
@ -563,7 +574,8 @@ int fgMainInit( int argc, char **argv )
|
|||
const bool readOnlyFGHome = fgGetBool("/sim/fghome-readonly");
|
||||
if (!readOnlyFGHome) {
|
||||
// now home is initialised, we can log to a file inside it
|
||||
logToHome();
|
||||
const auto level = flightgear::Options::getArgValue(argc, argv, "--log-level");
|
||||
logToHome(level);
|
||||
}
|
||||
|
||||
if (readOnlyFGHome) {
|
||||
|
|
Loading…
Reference in a new issue