From 622e4d7f25c2b12087f6c50dd82cb8969a5a6b2b Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Mon, 21 Oct 2013 14:15:21 +0200 Subject: [PATCH] Start log flush timer after binding the stream. refs #4890 --- lib/base/streamlogger.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/base/streamlogger.cpp b/lib/base/streamlogger.cpp index 910b1dc39..09ec40ca7 100644 --- a/lib/base/streamlogger.cpp +++ b/lib/base/streamlogger.cpp @@ -39,11 +39,6 @@ void StreamLogger::Start(void) m_Stream = NULL; m_OwnsStream = false; m_Tty = false; - - m_FlushLogTimer = boost::make_shared(); - m_FlushLogTimer->SetInterval(1); - m_FlushLogTimer->OnTimerExpired.connect(boost::bind(&StreamLogger::FlushLogTimerHandler, this)); - m_FlushLogTimer->Start(); } /** @@ -57,8 +52,7 @@ StreamLogger::~StreamLogger(void) void StreamLogger::FlushLogTimerHandler(void) { - if (m_OwnsStream && m_Stream) - m_Stream->flush(); + m_Stream->flush(); } void StreamLogger::BindStream(std::ostream *stream, bool ownsStream) @@ -68,6 +62,11 @@ void StreamLogger::BindStream(std::ostream *stream, bool ownsStream) m_Stream = stream; m_OwnsStream = ownsStream; m_Tty = IsTty(*stream); + + m_FlushLogTimer = boost::make_shared(); + m_FlushLogTimer->SetInterval(1); + m_FlushLogTimer->OnTimerExpired.connect(boost::bind(&StreamLogger::FlushLogTimerHandler, this)); + m_FlushLogTimer->Start(); } /** -- 2.40.0