Loading ndb/include/logger/LogHandler.hpp +10 −0 Original line number Diff line number Diff line Loading @@ -192,6 +192,16 @@ private: const char* m_pDateTimeFormat; int m_errorCode; // for handling repeated messages unsigned m_count_repeated_messages; unsigned m_max_repeat_frequency; time_t m_last_log_time; char m_last_category_buf[16]; char m_last_message_buf[256]; char *m_last_category; Logger::LoggerLevel m_last_level; char *m_last_message; }; #endif ndb/src/common/logger/LogHandler.cpp +54 −5 Original line number Diff line number Diff line Loading @@ -23,21 +23,70 @@ // LogHandler::LogHandler() : m_pDateTimeFormat("%d-%.2d-%.2d %.2d:%.2d:%.2d"), m_errorCode(0) m_errorCode(0), m_last_category(m_last_category_buf), m_last_message(m_last_message_buf) { m_max_repeat_frequency= 3; // repeat messages maximum every 3 seconds m_last_category_buf[0]= 0; m_last_message_buf[0]= 0; } LogHandler::~LogHandler() { if (m_last_message != m_last_message_buf) free(m_last_message); if (m_last_category != m_last_category_buf) free(m_last_category); } void LogHandler::append(const char* pCategory, Logger::LoggerLevel level, const char* pMsg) { time_t now; now= ::time((time_t*)NULL); if (level != m_last_level || strcmp(pCategory, m_last_category) || strcmp(pMsg, m_last_message)) { if (m_last_message != m_last_message_buf) free(m_last_message); if (m_last_category != m_last_category_buf) free(m_last_category); m_count_repeated_messages= 0; m_last_level= level; BaseString::snprintf(m_last_category_buf, sizeof(m_last_category_buf), "%s", pCategory); BaseString::snprintf(m_last_message_buf, sizeof(m_last_message_buf), "%s", pMsg); // ToDo: handle too long messages correctly // right now all that will happen is that too long messages // will be repeated unneccesarily } else // repeated message { if (now < m_last_log_time+m_max_repeat_frequency) { m_count_repeated_messages++; return; } } writeHeader(pCategory, level); if (m_count_repeated_messages == 0) writeMessage(pMsg); else { BaseString str(pMsg); str.appfmt(" - repeated %d times", m_count_repeated_messages); writeMessage(str.c_str()); m_count_repeated_messages= 0; } writeFooter(); m_last_log_time= now; } const char* Loading ndb/src/common/transporter/Transporter.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ Transporter::getRemoteNodeId() const { inline NodeId Transporter::getLocalNodeId() const { return remoteNodeId; return localNodeId; } inline Loading Loading
ndb/include/logger/LogHandler.hpp +10 −0 Original line number Diff line number Diff line Loading @@ -192,6 +192,16 @@ private: const char* m_pDateTimeFormat; int m_errorCode; // for handling repeated messages unsigned m_count_repeated_messages; unsigned m_max_repeat_frequency; time_t m_last_log_time; char m_last_category_buf[16]; char m_last_message_buf[256]; char *m_last_category; Logger::LoggerLevel m_last_level; char *m_last_message; }; #endif
ndb/src/common/logger/LogHandler.cpp +54 −5 Original line number Diff line number Diff line Loading @@ -23,21 +23,70 @@ // LogHandler::LogHandler() : m_pDateTimeFormat("%d-%.2d-%.2d %.2d:%.2d:%.2d"), m_errorCode(0) m_errorCode(0), m_last_category(m_last_category_buf), m_last_message(m_last_message_buf) { m_max_repeat_frequency= 3; // repeat messages maximum every 3 seconds m_last_category_buf[0]= 0; m_last_message_buf[0]= 0; } LogHandler::~LogHandler() { if (m_last_message != m_last_message_buf) free(m_last_message); if (m_last_category != m_last_category_buf) free(m_last_category); } void LogHandler::append(const char* pCategory, Logger::LoggerLevel level, const char* pMsg) { time_t now; now= ::time((time_t*)NULL); if (level != m_last_level || strcmp(pCategory, m_last_category) || strcmp(pMsg, m_last_message)) { if (m_last_message != m_last_message_buf) free(m_last_message); if (m_last_category != m_last_category_buf) free(m_last_category); m_count_repeated_messages= 0; m_last_level= level; BaseString::snprintf(m_last_category_buf, sizeof(m_last_category_buf), "%s", pCategory); BaseString::snprintf(m_last_message_buf, sizeof(m_last_message_buf), "%s", pMsg); // ToDo: handle too long messages correctly // right now all that will happen is that too long messages // will be repeated unneccesarily } else // repeated message { if (now < m_last_log_time+m_max_repeat_frequency) { m_count_repeated_messages++; return; } } writeHeader(pCategory, level); if (m_count_repeated_messages == 0) writeMessage(pMsg); else { BaseString str(pMsg); str.appfmt(" - repeated %d times", m_count_repeated_messages); writeMessage(str.c_str()); m_count_repeated_messages= 0; } writeFooter(); m_last_log_time= now; } const char* Loading
ndb/src/common/transporter/Transporter.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ Transporter::getRemoteNodeId() const { inline NodeId Transporter::getLocalNodeId() const { return remoteNodeId; return localNodeId; } inline Loading