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