mirror of https://github.com/Icinga/icinga2.git
WorkQueue: Allow choosing stats log level
This commit is contained in:
parent
2dfe777f48
commit
3c556350c8
|
@ -14,9 +14,9 @@ using namespace icinga;
|
|||
std::atomic<int> WorkQueue::m_NextID(1);
|
||||
boost::thread_specific_ptr<WorkQueue *> l_ThreadWorkQueue;
|
||||
|
||||
WorkQueue::WorkQueue(size_t maxItems, int threadCount)
|
||||
WorkQueue::WorkQueue(size_t maxItems, int threadCount, LogSeverity statsLogLevel)
|
||||
: m_ID(m_NextID++), m_ThreadCount(threadCount), m_MaxItems(maxItems),
|
||||
m_TaskStats(15 * 60)
|
||||
m_TaskStats(15 * 60), m_StatsLogLevel(statsLogLevel)
|
||||
{
|
||||
/* Initialize logger. */
|
||||
m_StatusTimerTimeout = Utility::GetTime();
|
||||
|
@ -216,7 +216,7 @@ void WorkQueue::StatusTimerHandler()
|
|||
|
||||
/* Log if there are pending items, or 5 minute timeout is reached. */
|
||||
if (pending > 0 || m_StatusTimerTimeout < now) {
|
||||
Log(LogInformation, "WorkQueue")
|
||||
Log(m_StatsLogLevel, "WorkQueue")
|
||||
<< "#" << m_ID << " (" << m_Name << ") "
|
||||
<< "items: " << pending << ", "
|
||||
<< "rate: " << std::setw(2) << GetTaskCount(60) / 60.0 << "/s "
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "base/i2-base.hpp"
|
||||
#include "base/timer.hpp"
|
||||
#include "base/ringbuffer.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
|
@ -52,7 +53,7 @@ class WorkQueue
|
|||
public:
|
||||
typedef std::function<void (boost::exception_ptr)> ExceptionCallback;
|
||||
|
||||
WorkQueue(size_t maxItems = 0, int threadCount = 1);
|
||||
WorkQueue(size_t maxItems = 0, int threadCount = 1, LogSeverity statsLogLevel = LogInformation);
|
||||
~WorkQueue();
|
||||
|
||||
void SetName(const String& name);
|
||||
|
@ -129,6 +130,7 @@ private:
|
|||
std::vector<boost::exception_ptr> m_Exceptions;
|
||||
Timer::Ptr m_StatusTimer;
|
||||
double m_StatusTimerTimeout;
|
||||
LogSeverity m_StatsLogLevel;
|
||||
|
||||
RingBuffer m_TaskStats;
|
||||
size_t m_PendingTasks{0};
|
||||
|
|
Loading…
Reference in New Issue