Ticket #1704: log4cplus-1.0.4-clog.patch

File log4cplus-1.0.4-clog.patch, 1.7 KB (added by muks, 8 years ago)

Patch for log4cplus to use clog instead of cerr, which writes to stderr and is buffered

  • include/log4cplus/streams.h

    diff -ru log4cplus-1.0.4/include/log4cplus/streams.h log4cplus-1.0.4.modified/include/log4cplus/streams.h
    old new  
    3737        typedef LOG4CPLUS_STREAM_NAMESPACE::wostringstream tostringstream;
    3838        static tostream &tcout = LOG4CPLUS_STREAM_NAMESPACE::wcout;
    3939        static tostream &tcerr = LOG4CPLUS_STREAM_NAMESPACE::wcerr;
     40        static tostream &tclog = LOG4CPLUS_STREAM_NAMESPACE::wclog;
    4041    }
    4142
    4243LOG4CPLUS_EXPORT log4cplus::tostream& operator <<(log4cplus::tostream&, const char* psz );
     
    4748        typedef LOG4CPLUS_STREAM_NAMESPACE::istream tistream;
    4849        static tostream &tcout = LOG4CPLUS_STREAM_NAMESPACE::cout;
    4950        static tostream &tcerr = LOG4CPLUS_STREAM_NAMESPACE::cerr;
     51        static tostream &tclog = LOG4CPLUS_STREAM_NAMESPACE::clog;
    5052        typedef LOG4CPLUS_STREAM_NAMESPACE::ostringstream tostringstream;
    5153    }
    5254#endif // UNICODE
  • src/consoleappender.cxx

    diff -ru log4cplus-1.0.4/src/consoleappender.cxx log4cplus-1.0.4.modified/src/consoleappender.cxx
    old new  
    9090log4cplus::ConsoleAppender::append(const spi::InternalLoggingEvent& event)
    9191{
    9292    LOG4CPLUS_BEGIN_SYNCHRONIZE_ON_MUTEX( getLogLog().mutex )
    93         log4cplus::tostream& output = (logToStdErr ? tcerr : tcout);
     93        log4cplus::tostream& output = (logToStdErr ? tclog : tcout);
    9494        layout->formatAndAppend(output, event);
    9595        if(immediateFlush) {
    9696            output.flush();