From Lionel Lagarde, "When a function do:

OSG_DEBUG << "Hello world!\n";

the underlying stream is not automatically flushed. It is flushed
if endl is queued instead of \n:

OSG_DEBUG << "Hello world!" << std::endl;


The notify macros do:
stream->setCurrentSeverity(severity);
return *stream;

So, if a function do:

OSG_DEBUG << "This is a debug message\n";
OSG_NOTICE << "This is a notice message" << std::endl;

the debug message will be classified as a notice message.

It is a problem when the application uses a NotifyHandler. The notify
method of the handler is called with:

severity = NOTICE
message = "This is a debug message\nThis is a notice message"

The attached Notify.cpp contains an automatic flush of the stream when
the current severity changes.

"
This commit is contained in:
Robert Osfield
2013-05-14 16:23:53 +00:00
parent c238a7cca2
commit 07499f6658

View File

@@ -65,7 +65,15 @@ struct NotifyStreamBuffer : public std::stringbuf
osg::NotifyHandler *getNotifyHandler() const { return _handler.get(); }
/** Sets severity for next call of notify handler */
void setCurrentSeverity(osg::NotifySeverity severity) { _severity = severity; }
void setCurrentSeverity(osg::NotifySeverity severity)
{
if (_severity != severity)
{
sync();
_severity = severity;
}
}
osg::NotifySeverity getCurrentSeverity() const { return _severity; }
private: