Some additional comments on the patch are available at the bug report, LOGCXX-18. The major difference is that this logstream is derived from std::basic_stream and can be passed to methods expecting that stream. The insertion operator will typically be short-circuited when the concrete type is known and the logger is disabled (at least that is the intent, haven't confirmed it). If the concrete type is lost (as when passed as a ostream&) or for custom insertion operations, the insertion operation will still be performed, but the message will be discarded.
The log events are raised when the stream is flushed. Inserting LOG4CXX_ENDMSG will set the location and flush the message. Changed the name from ENDL since no new-line is actually added.
Sample usage:
log4cxx::logstream ls("org.example.someapp", log4cxx::Level::DEBUG);
log4cxx::logstream ls2(logger, log4cxx::Level::DEBUG);ls << "This is a debug msg " << 3.1415926 << LOG4CXX_ENDMSG;
ls << log4cxx::Level::WARN << "This is a warn message " << LOG4CXX_ENDMSG;
// can still conditionalize expensive operations if (ls.isEnabled()) {
}
