Start log flush timer after binding the stream.

refs #4890
This commit is contained in:
Michael Friedrich 2013-10-21 14:15:21 +02:00
parent 07d9a59fe0
commit 622e4d7f25
1 changed files with 6 additions and 7 deletions

View File

@ -39,11 +39,6 @@ void StreamLogger::Start(void)
m_Stream = NULL; m_Stream = NULL;
m_OwnsStream = false; m_OwnsStream = false;
m_Tty = false; m_Tty = false;
m_FlushLogTimer = boost::make_shared<Timer>();
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) void StreamLogger::FlushLogTimerHandler(void)
{ {
if (m_OwnsStream && m_Stream) m_Stream->flush();
m_Stream->flush();
} }
void StreamLogger::BindStream(std::ostream *stream, bool ownsStream) void StreamLogger::BindStream(std::ostream *stream, bool ownsStream)
@ -68,6 +62,11 @@ void StreamLogger::BindStream(std::ostream *stream, bool ownsStream)
m_Stream = stream; m_Stream = stream;
m_OwnsStream = ownsStream; m_OwnsStream = ownsStream;
m_Tty = IsTty(*stream); m_Tty = IsTty(*stream);
m_FlushLogTimer = boost::make_shared<Timer>();
m_FlushLogTimer->SetInterval(1);
m_FlushLogTimer->OnTimerExpired.connect(boost::bind(&StreamLogger::FlushLogTimerHandler, this));
m_FlushLogTimer->Start();
} }
/** /**