flags = flags_;
}
+template <typename charT, typename traits>
+void DoutStreambuf<charT, traits>::
+set_prio(int prio)
+{
+ charT* p = this->pptr();
+ *p++ = '\1';
+ *p++ = ((unsigned char)prio);
+ this->pbump(2);
+}
+
// This is called to flush the buffer.
// This is called when we're done with the file stream (or when .flush() is called).
template <typename charT, typename traits>
// Set the flags directly (for debug use only)
void set_flags(int flags_);
+ // Set the priority of the messages being put into the stream
+ void set_prio(int prio);
+
protected:
// Called when the buffer fills up
virtual int_type overflow(int_type c);
_dout_lock.Lock();
dos->set_flags(DoutStreambuf<char>::DOUTSB_FLAG_SYSLOG |
- DoutStreambuf<char>::DOUTSB_FLAG_STDOUT);
+ DoutStreambuf<char>::DOUTSB_FLAG_STDERR);
_dout_lock.Unlock();
std::ostream oss(dos);
syslog(LOG_USER | LOG_NOTICE, "TestDoutStreambuf: starting test\n");
+ dos->set_prio(1);
oss << "I am logging to dout now!" << std::endl;
+ dos->set_prio(2);
oss << "And here is another line!" << std::endl;
oss.flush();
+ dos->set_prio(3);
+ oss << "And here is another line!" << std::endl;
+
+ dos->set_prio(16);
oss << "Stuff ";
oss << "that ";
oss << "will ";
oss << "line.";
oss.flush();
+ dos->set_prio(10);
oss << "There will be no blank lines here." << std::endl;
oss.flush();
oss.flush();