19 #include "LogHandler.hpp"
27 m_pDateTimeFormat(
"%d-%.2d-%.2d %.2d:%.2d:%.2d"),
31 m_max_repeat_frequency= 3;
32 m_count_repeated_messages= 0;
33 m_last_category[0]= 0;
49 now= ::time((time_t*)NULL);
51 if (m_max_repeat_frequency == 0 ||
52 level != m_last_level ||
53 strcmp(pCategory, m_last_category) ||
54 strcmp(pMsg, m_last_message))
56 if (m_count_repeated_messages > 0)
57 append_impl(m_last_category, m_last_level, m_last_message);
60 strncpy(m_last_category, pCategory,
sizeof(m_last_category));
61 strncpy(m_last_message, pMsg,
sizeof(m_last_message));
65 if (now < (time_t) (m_last_log_time+m_max_repeat_frequency))
67 m_count_repeated_messages++;
75 append_impl(pCategory, level, pMsg);
84 if (m_count_repeated_messages <= 1)
89 str.appfmt(
" - Repeated %d times", m_count_repeated_messages);
92 m_count_repeated_messages= 0;
100 char time[MAX_DATE_TIME_HEADER_LENGTH];
102 getTimeAsString((
char*)time),
119 return m_pDateTimeFormat;
125 m_pDateTimeFormat = (
char*)pFormat;
129 LogHandler::getTimeAsString(
char* pStr)
const
132 tm_now = ::localtime(&m_now);
136 tm_now->tm_year + 1900,
168 m_errorStr= (
char*) str;
177 _params.
split(v_args,
",");
178 for(
size_t i=0;
i < v_args.size();
i++) {
180 if(v_args[
i].split(v_param_value,
"=", 2) != 2)
187 v_param_value[0].trim(
" \t");
188 if (!
setParam(v_param_value[0], v_param_value[1]))
205 void LogHandler::setRepeatFrequency(
unsigned val)
207 m_max_repeat_frequency= val;