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) {
|
if (!qtInitDone) {
|
||||||
qtInitDone = true;
|
qtInitDone = true;
|
||||||
|
|
||||||
sglog().setLogLevels( SG_ALL, SG_INFO );
|
|
||||||
initQtResources(); // can't be called from a namespace
|
initQtResources(); // can't be called from a namespace
|
||||||
|
|
||||||
s_argc = argc; // QApplication only stores a reference to argc,
|
s_argc = argc; // QApplication only stores a reference to argc,
|
||||||
|
|
|
@ -194,20 +194,18 @@ setLoggingPriority (const char * p)
|
||||||
{
|
{
|
||||||
if (p == 0)
|
if (p == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string priority = p;
|
string priority = p;
|
||||||
if (priority == "bulk") {
|
if (priority.empty()) {
|
||||||
sglog().set_log_priority(SG_BULK);
|
|
||||||
} else if (priority == "debug") {
|
|
||||||
sglog().set_log_priority(SG_DEBUG);
|
|
||||||
} else if (priority.empty() || priority == "info") { // default
|
|
||||||
sglog().set_log_priority(SG_INFO);
|
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 {
|
} 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());
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Logging priority is " << getLoggingPriority());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -506,8 +506,18 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#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();
|
SGPath logPath = globals->get_fg_home();
|
||||||
logPath.append("fgfs.log");
|
logPath.append("fgfs.log");
|
||||||
if (logPath.exists()) {
|
if (logPath.exists()) {
|
||||||
|
@ -518,7 +528,8 @@ static void logToHome()
|
||||||
logPath = globals->get_fg_home();
|
logPath = globals->get_fg_home();
|
||||||
logPath.append("fgfs.log");
|
logPath.append("fgfs.log");
|
||||||
}
|
}
|
||||||
sglog().logToFile(logPath, SG_ALL, SG_INFO);
|
|
||||||
|
sglog().logToFile(logPath, SG_ALL, fileLogLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main top level initialization
|
// Main top level initialization
|
||||||
|
@ -563,7 +574,8 @@ int fgMainInit( int argc, char **argv )
|
||||||
const bool readOnlyFGHome = fgGetBool("/sim/fghome-readonly");
|
const bool readOnlyFGHome = fgGetBool("/sim/fghome-readonly");
|
||||||
if (!readOnlyFGHome) {
|
if (!readOnlyFGHome) {
|
||||||
// now home is initialised, we can log to a file inside it
|
// 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) {
|
if (readOnlyFGHome) {
|
||||||
|
|
Loading…
Reference in a new issue