From: Michael Friedrich Date: Mon, 21 Oct 2013 12:15:21 +0000 (+0200) Subject: Start log flush timer after binding the stream. X-Git-Tag: v0.0.3~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=622e4d7f25c2b12087f6c50dd82cb8969a5a6b2b;p=icinga2 Start log flush timer after binding the stream. refs #4890 --- 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(); } /**