From 213adb5f0d9d2d70f7dd974dc440f1705c25d8c6 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Tue, 31 Dec 2019 11:50:56 +0000 Subject: [PATCH] simgear/debug/logstream.cxx: ensure fgfs.log always includes file:line. This is a bit of a hack - we set line = -line if m_fileLine is false, so that the +ve value can be recovered by FileLogCallback::operator(). --- simgear/debug/logstream.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/simgear/debug/logstream.cxx b/simgear/debug/logstream.cxx index 952eba16..fe4dac42 100644 --- a/simgear/debug/logstream.cxx +++ b/simgear/debug/logstream.cxx @@ -159,11 +159,13 @@ public: << std::left << debugClassToString(c) ; - if (file && line != -1) { + if (file) { + /* can be -ve to indicate that m_fileLine was false, but we + want to show file:line information regardless of m_fileLine. */ m_file << file << ":" - << line + << abs(line) << ": " ; } @@ -200,7 +202,7 @@ public: if (!shouldLog(c, p)) return; //fprintf(stderr, "%s\n", aMessage.c_str()); - if (file && line != -1) { + if (file && line > 0) { fprintf(stderr, "%8.2f %s:%i: [%.8s]:%-10s %s\n", logTimer.elapsedMSec()/1000.0, file, line, debugPriorityToString(p), debugClassToString(c), aMessage.c_str()); } else { @@ -548,8 +550,8 @@ public: { p = translatePriority(p); if (!m_fileLine) { - /* This prevents output of file:line. */ - line = -1; + /* This prevents output of file:line in StderrLogCallback. */ + line = -line; } LogEntry entry(c, p, fileName, line, msg); m_entries.push(entry);