TestSuite: Always capture OSG logging.
The NotifyLogger class from src/Viewer/fg_os_osgviewer.cxx has been shifted into a simgear header file so that it can be reused within the test suite.
This commit is contained in:
parent
acb3307a1a
commit
63d751c15e
2 changed files with 6 additions and 42 deletions
|
@ -34,6 +34,7 @@
|
|||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/debug/OsgIoCapture.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
|
||||
#include <osg/Camera>
|
||||
|
@ -183,48 +184,6 @@ static const char * getStereoMode()
|
|||
return "OFF";
|
||||
}
|
||||
|
||||
/**
|
||||
* merge OSG output into our logging system, so it gets recorded to file,
|
||||
* and so we can display a GUI console with renderer issues, especially
|
||||
* shader compilation warnings and errors.
|
||||
*/
|
||||
class NotifyLogger : public osg::NotifyHandler
|
||||
{
|
||||
public:
|
||||
// note this callback will be invoked by OSG from multiple threads.
|
||||
// fortunately our Simgear logging implementation already handles
|
||||
// that internally, so we simply pass the message on.
|
||||
virtual void notify(osg::NotifySeverity severity, const char *message)
|
||||
{
|
||||
// Detect whether a osg::Reference derived object is deleted with a non-zero
|
||||
// reference count. In this case trigger a segfault to get a stack trace.
|
||||
if( strstr(message, "the final reference count was") )
|
||||
{
|
||||
// as this is going to segfault ignore the translation of severity and always output the message.
|
||||
SG_LOG(SG_GL, SG_ALERT, message);
|
||||
int* trigger_segfault = 0;
|
||||
*trigger_segfault = 0;
|
||||
return;
|
||||
}
|
||||
SG_LOG(SG_GL, translateSeverity(severity), message);
|
||||
}
|
||||
|
||||
private:
|
||||
sgDebugPriority translateSeverity(osg::NotifySeverity severity)
|
||||
{
|
||||
switch (severity) {
|
||||
case osg::ALWAYS:
|
||||
case osg::FATAL: return SG_ALERT;
|
||||
case osg::WARN: return SG_WARN;
|
||||
case osg::NOTICE:
|
||||
case osg::INFO: return SG_INFO;
|
||||
case osg::DEBUG_FP:
|
||||
case osg::DEBUG_INFO: return SG_DEBUG;
|
||||
default: return SG_ALERT;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class NotifyLevelListener : public SGPropertyChangeListener
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "logging.hxx"
|
||||
|
||||
#include <simgear/debug/OsgIoCapture.hxx>
|
||||
|
||||
|
||||
// The global stream capture data structure.
|
||||
static capturedIO *_iostreams = NULL;
|
||||
|
@ -70,6 +72,9 @@ void setupLogging()
|
|||
// Set up the logstream testing mode.
|
||||
log.setTestingMode(true);
|
||||
|
||||
// OSG IO capture.
|
||||
osg::setNotifyHandler(new NotifyLogger);
|
||||
|
||||
// IO capture.
|
||||
capturedIO &obj = getIOstreams();
|
||||
log.addCallback(obj.callback_bulk);
|
||||
|
|
Loading…
Add table
Reference in a new issue