mirror of https://github.com/Icinga/icinga2.git
parent
10b2740dbe
commit
07d9a59fe0
|
@ -21,6 +21,7 @@
|
|||
#include "base/utility.h"
|
||||
#include "base/objectlock.h"
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -38,6 +39,11 @@ void StreamLogger::Start(void)
|
|||
m_Stream = NULL;
|
||||
m_OwnsStream = 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,6 +55,12 @@ StreamLogger::~StreamLogger(void)
|
|||
delete m_Stream;
|
||||
}
|
||||
|
||||
void StreamLogger::FlushLogTimerHandler(void)
|
||||
{
|
||||
if (m_OwnsStream && m_Stream)
|
||||
m_Stream->flush();
|
||||
}
|
||||
|
||||
void StreamLogger::BindStream(std::ostream *stream, bool ownsStream)
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "base/i2-base.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/timer.h"
|
||||
#include <ostream>
|
||||
|
||||
namespace icinga
|
||||
|
@ -53,6 +54,10 @@ private:
|
|||
std::ostream *m_Stream;
|
||||
bool m_OwnsStream;
|
||||
bool m_Tty;
|
||||
|
||||
Timer::Ptr m_FlushLogTimer;
|
||||
|
||||
void FlushLogTimerHandler(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue