Merge branch 'next' of https://git.code.sf.net/p/flightgear/simgear into next
This commit is contained in:
@@ -335,9 +335,7 @@ public:
|
||||
|
||||
~LogStreamPrivate()
|
||||
{
|
||||
for (simgear::LogCallback* cb : m_callbacks) {
|
||||
delete cb;
|
||||
}
|
||||
removeCallbacks();
|
||||
}
|
||||
|
||||
SGMutex m_lock;
|
||||
@@ -363,6 +361,9 @@ public:
|
||||
#endif
|
||||
bool m_developerMode = false;
|
||||
|
||||
// test suite mode.
|
||||
bool m_testMode = false;
|
||||
|
||||
void startLog()
|
||||
{
|
||||
SGGuard<SGMutex> g(m_lock);
|
||||
@@ -443,6 +444,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void removeCallbacks()
|
||||
{
|
||||
PauseThread pause(this);
|
||||
for (simgear::LogCallback* cb : m_callbacks) {
|
||||
delete cb;
|
||||
}
|
||||
m_callbacks.clear();
|
||||
m_consoleCallbacks.clear();
|
||||
}
|
||||
|
||||
void setLogLevels( sgDebugClass c, sgDebugPriority p )
|
||||
{
|
||||
PauseThread pause(this);
|
||||
@@ -455,6 +466,9 @@ public:
|
||||
|
||||
bool would_log( sgDebugClass c, sgDebugPriority p ) const
|
||||
{
|
||||
// Testing mode, so always log.
|
||||
if (m_testMode) return true;
|
||||
|
||||
p = translatePriority(p);
|
||||
if (p >= SG_INFO) return true;
|
||||
return ((c & m_logClass) != 0 && p >= m_logPriority);
|
||||
@@ -711,6 +725,13 @@ void logstream::requestConsole()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
logstream::setTestingMode( bool testMode )
|
||||
{
|
||||
d->m_testMode = testMode;
|
||||
if (testMode) d->removeCallbacks();
|
||||
}
|
||||
|
||||
|
||||
namespace simgear
|
||||
{
|
||||
|
||||
@@ -158,12 +158,22 @@ public:
|
||||
|
||||
void removeCallback(simgear::LogCallback* cb);
|
||||
|
||||
void removeCallbacks();
|
||||
|
||||
/**
|
||||
* optionally record all entries and submit them to new log callbacks that
|
||||
* are added. This allows simplified logging configuration, but still including
|
||||
* early startup information in all logs.
|
||||
*/
|
||||
void setStartupLoggingEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* Set up the logstream for running in test mode. For example the callbacks
|
||||
* will be unregistered and the behaviour of the would_log() function
|
||||
* sanitized.
|
||||
*/
|
||||
void setTestingMode(bool testMode);
|
||||
|
||||
private:
|
||||
// constructor
|
||||
logstream();
|
||||
|
||||
Reference in New Issue
Block a user