diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index c03d1545..2891da91 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -63,6 +63,7 @@ string AmConfig::Application = ""; AmConfig::ApplicationSelector AmConfig::AppSelect = AmConfig::App_SPECIFIED; AmConfig::AppMappingVector AmConfig::AppMapping; bool AmConfig::LogSessions = false; +bool AmConfig::LogEvents = false; int AmConfig::UnhandledReplyLoglevel = 0; unsigned int AmConfig::SessionLimit = 0; @@ -224,6 +225,7 @@ int AmConfig::readConfiguration() } LogSessions = cfg.getParameter("log_sessions")=="yes"; + LogEvents = cfg.getParameter("log_events")=="yes"; if (cfg.hasParameter("unhandled_reply_loglevel")) { string msglog = cfg.getParameter("unhandled_reply_loglevel"); diff --git a/core/AmConfig.h b/core/AmConfig.h index 9388542b..f99d7408 100644 --- a/core/AmConfig.h +++ b/core/AmConfig.h @@ -122,6 +122,8 @@ struct AmConfig static bool LogSessions; + static bool LogEvents; + static int UnhandledReplyLoglevel; /** Init function. Resolves SMTP server address. */ diff --git a/core/AmEventQueue.cpp b/core/AmEventQueue.cpp index bdc55cc0..712a179f 100644 --- a/core/AmEventQueue.cpp +++ b/core/AmEventQueue.cpp @@ -27,6 +27,7 @@ #include "AmEventQueue.h" #include "log.h" +#include "AmConfig.h" AmEventQueue::AmEventQueue(AmEventHandler* handler) : handler(handler),ev_pending(false) @@ -45,7 +46,8 @@ AmEventQueue::~AmEventQueue() void AmEventQueue::postEvent(AmEvent* event) { - DBG("AmEventQueue: trying to post event\n"); + if (AmConfig::LogEvents) + DBG("AmEventQueue: trying to post event\n"); m_queue.lock(); if(event) @@ -53,7 +55,8 @@ void AmEventQueue::postEvent(AmEvent* event) ev_pending.set(true); m_queue.unlock(); - DBG("AmEventQueue: event posted\n"); + if (AmConfig::LogEvents) + DBG("AmEventQueue: event posted\n"); } void AmEventQueue::processEvents() @@ -66,9 +69,11 @@ void AmEventQueue::processEvents() ev_queue.pop(); m_queue.unlock(); - DBG("before processing event\n"); + if (AmConfig::LogEvents) + DBG("before processing event\n"); handler->process(event); - DBG("event processed\n"); + if (AmConfig::LogEvents) + DBG("event processed\n"); delete event; m_queue.lock(); } @@ -97,9 +102,11 @@ void AmEventQueue::processSingleEvent() ev_queue.pop(); m_queue.unlock(); - DBG("before processing event\n"); + if (AmConfig::LogEvents) + DBG("before processing event\n"); handler->process(event); - DBG("event processed\n"); + if (AmConfig::LogEvents) + DBG("event processed\n"); delete event; m_queue.lock(); diff --git a/core/etc/sems.conf.sample b/core/etc/sems.conf.sample index 84c0a284..abfccd05 100644 --- a/core/etc/sems.conf.sample +++ b/core/etc/sems.conf.sample @@ -210,6 +210,16 @@ loglevel=2 # # log_sessions=yes +# optional parameter: log_events=[yes|no] +# +# Default: no +# +# If log_eventy=yes is set, generic DBG level log messages are +# generated for each event that is posted into an event queue. +# +# log_events=yes + + ############################################################ # tuning