From: <sv...@ww...> - 2006-12-12 08:04:46
|
Author: mkrose Date: 2006-12-12 00:04:39 -0800 (Tue, 12 Dec 2006) New Revision: 2031 Modified: trunk/csp/csplib/util/LogStream.cpp trunk/csp/csplib/util/LogStream.h Log: Move ~LogEntry out of the header and expose LogEntry::BufferStream. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2031 Modified: trunk/csp/csplib/util/LogStream.cpp =================================================================== --- trunk/csp/csplib/util/LogStream.cpp 2006-12-11 13:29:30 UTC (rev 2030) +++ trunk/csp/csplib/util/LogStream.cpp 2006-12-12 08:04:39 UTC (rev 2031) @@ -230,6 +230,14 @@ ::abort(); } +LogStream::LogEntry::~LogEntry() { + m_stream.lock(); + m_stream.getStream() << m_buffer.get() << "\n"; + if (m_priority >= LogStream::cWarning || m_stream.autoflush()) m_stream.flush(); + m_stream.unlock(); + if (m_priority == LogStream::cFatal) die(); +} + LogStream *LogStream::getOrCreateNamedLog(const std::string &name, bool *created) { if (created) *created = false; if (!NamedLogStreamRegistry) NamedLogStreamRegistry = new LogStreamRegistry; Modified: trunk/csp/csplib/util/LogStream.h =================================================================== --- trunk/csp/csplib/util/LogStream.h 2006-12-11 13:29:30 UTC (rev 2030) +++ trunk/csp/csplib/util/LogStream.h 2006-12-12 08:04:39 UTC (rev 2031) @@ -241,13 +241,7 @@ * write operation if running in a multithreaded environment. If the priority * is cFatal, records a stack trace and aborts the program. */ - ~LogEntry() { - m_stream.lock(); - m_stream.getStream() << m_buffer.get() << "\n"; - if (m_priority >= LogStream::cWarning || m_stream.autoflush()) m_stream.flush(); - m_stream.unlock(); - if (m_priority == LogStream::cFatal) die(); - } + ~LogEntry(); /** Stream operator for recording messages in the log entry. */ @@ -263,10 +257,6 @@ return *this; } -private: - void prefix(const char *file, int linenum); - void die(); - /** A fixed size string stream used to buffer the log entry text internally * before writing the completed string to the log stream. */ @@ -278,6 +268,10 @@ FixedStringBuffer<512> m_buffer; }; +private: + void prefix(const char *file, int linenum); + void die(); + LogStream &m_stream; int m_priority; BufferStream m_buffer; |