Loading ndb/include/logger/LogHandler.hpp +13 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,18 @@ public: */ void setErrorCode(int code); /** * Returns the error string. */ char* getErrorStr(); /** * Sets the error string. * * @param str the error string. */ void setErrorStr(char* str); /** * Parse logstring parameters * Loading Loading @@ -195,6 +207,7 @@ private: const char* m_pDateTimeFormat; int m_errorCode; char* m_errorStr; // for handling repeated messages unsigned m_count_repeated_messages; Loading ndb/include/logger/Logger.hpp +4 −1 Original line number Diff line number Diff line Loading @@ -178,8 +178,11 @@ public: * Add a new handler * * @param logstring string describing the handler to add * @param err OS errno in event of error * @param len max length of errStr buffer * @param errStr logger error string in event of error */ bool addHandler(const BaseString &logstring); bool addHandler(const BaseString &logstring, int *err, int len, char* errStr); /** * Remove a log handler. Loading ndb/src/common/logger/FileLogHandler.cpp +13 −4 Original line number Diff line number Diff line Loading @@ -187,6 +187,7 @@ FileLogHandler::setParam(const BaseString ¶m, const BaseString &value){ return setMaxSize(value); if(param == "maxfiles") return setMaxFiles(value); setErrorStr("Invalid parameter"); return false; } Loading @@ -196,16 +197,18 @@ FileLogHandler::setFilename(const BaseString &filename) { if(m_pLogFile) delete m_pLogFile; m_pLogFile = new File_class(filename.c_str(), "a+"); open(); return true; return open(); } bool FileLogHandler::setMaxSize(const BaseString &size) { char *end; long val = strtol(size.c_str(), &end, 0); /* XXX */ if(size.c_str() == end) if(size.c_str() == end || val < 0) { setErrorStr("Invalid file size"); return false; } if(end[0] == 'M') val *= 1024*1024; if(end[0] == 'k') Loading @@ -220,8 +223,11 @@ bool FileLogHandler::setMaxFiles(const BaseString &files) { char *end; long val = strtol(files.c_str(), &end, 0); if(files.c_str() == end) if(files.c_str() == end || val < 1) { setErrorStr("Invalid maximum number of files"); return false; } m_maxNoFiles = val; return true; Loading @@ -230,6 +236,9 @@ FileLogHandler::setMaxFiles(const BaseString &files) { bool FileLogHandler::checkParams() { if(m_pLogFile == NULL) { setErrorStr("Log file cannot be null."); return false; } return true; } ndb/src/common/logger/LogHandler.cpp +26 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,8 @@ // LogHandler::LogHandler() : m_pDateTimeFormat("%d-%.2d-%.2d %.2d:%.2d:%.2d"), m_errorCode(0) m_errorCode(0), m_errorStr(NULL) { m_max_repeat_frequency= 3; // repeat messages maximum every 3 seconds m_count_repeated_messages= 0; Loading Loading @@ -155,6 +156,19 @@ LogHandler::setErrorCode(int code) m_errorCode = code; } char* LogHandler::getErrorStr() { return m_errorStr; } void LogHandler::setErrorStr(char* str) { m_errorStr= str; } bool LogHandler::parseParams(const BaseString &_params) { Vector<BaseString> v_args; Loading @@ -165,10 +179,19 @@ LogHandler::parseParams(const BaseString &_params) { for(size_t i=0; i < v_args.size(); i++) { Vector<BaseString> v_param_value; if(v_args[i].split(v_param_value, "=", 2) != 2) { ret = false; else if (!setParam(v_param_value[0], v_param_value[1])) setErrorStr("Can't find key=value pair."); } else { v_param_value[0].trim(" \t"); if (!setParam(v_param_value[0], v_param_value[1])) { ret = false; } } } if(!checkParams()) ret = false; Loading ndb/src/common/logger/Logger.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ Logger::addHandler(LogHandler* pHandler) } bool Logger::addHandler(const BaseString &logstring) { Logger::addHandler(const BaseString &logstring, int *err, int len, char* errStr) { size_t i; Vector<BaseString> logdest; Vector<LogHandler *>loghandlers; Loading Loading @@ -200,9 +200,18 @@ Logger::addHandler(const BaseString &logstring) { handler = new ConsoleLogHandler(); if(handler == NULL) { snprintf(errStr,len,"Could not create log destination: %s", logdest[i].c_str()); DBUG_RETURN(false); } if(!handler->parseParams(params)) { *err= handler->getErrorCode(); if(handler->getErrorStr()) strncpy(errStr, handler->getErrorStr(), len); DBUG_RETURN(false); } loghandlers.push_back(handler); } Loading Loading
ndb/include/logger/LogHandler.hpp +13 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,18 @@ public: */ void setErrorCode(int code); /** * Returns the error string. */ char* getErrorStr(); /** * Sets the error string. * * @param str the error string. */ void setErrorStr(char* str); /** * Parse logstring parameters * Loading Loading @@ -195,6 +207,7 @@ private: const char* m_pDateTimeFormat; int m_errorCode; char* m_errorStr; // for handling repeated messages unsigned m_count_repeated_messages; Loading
ndb/include/logger/Logger.hpp +4 −1 Original line number Diff line number Diff line Loading @@ -178,8 +178,11 @@ public: * Add a new handler * * @param logstring string describing the handler to add * @param err OS errno in event of error * @param len max length of errStr buffer * @param errStr logger error string in event of error */ bool addHandler(const BaseString &logstring); bool addHandler(const BaseString &logstring, int *err, int len, char* errStr); /** * Remove a log handler. Loading
ndb/src/common/logger/FileLogHandler.cpp +13 −4 Original line number Diff line number Diff line Loading @@ -187,6 +187,7 @@ FileLogHandler::setParam(const BaseString ¶m, const BaseString &value){ return setMaxSize(value); if(param == "maxfiles") return setMaxFiles(value); setErrorStr("Invalid parameter"); return false; } Loading @@ -196,16 +197,18 @@ FileLogHandler::setFilename(const BaseString &filename) { if(m_pLogFile) delete m_pLogFile; m_pLogFile = new File_class(filename.c_str(), "a+"); open(); return true; return open(); } bool FileLogHandler::setMaxSize(const BaseString &size) { char *end; long val = strtol(size.c_str(), &end, 0); /* XXX */ if(size.c_str() == end) if(size.c_str() == end || val < 0) { setErrorStr("Invalid file size"); return false; } if(end[0] == 'M') val *= 1024*1024; if(end[0] == 'k') Loading @@ -220,8 +223,11 @@ bool FileLogHandler::setMaxFiles(const BaseString &files) { char *end; long val = strtol(files.c_str(), &end, 0); if(files.c_str() == end) if(files.c_str() == end || val < 1) { setErrorStr("Invalid maximum number of files"); return false; } m_maxNoFiles = val; return true; Loading @@ -230,6 +236,9 @@ FileLogHandler::setMaxFiles(const BaseString &files) { bool FileLogHandler::checkParams() { if(m_pLogFile == NULL) { setErrorStr("Log file cannot be null."); return false; } return true; }
ndb/src/common/logger/LogHandler.cpp +26 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,8 @@ // LogHandler::LogHandler() : m_pDateTimeFormat("%d-%.2d-%.2d %.2d:%.2d:%.2d"), m_errorCode(0) m_errorCode(0), m_errorStr(NULL) { m_max_repeat_frequency= 3; // repeat messages maximum every 3 seconds m_count_repeated_messages= 0; Loading Loading @@ -155,6 +156,19 @@ LogHandler::setErrorCode(int code) m_errorCode = code; } char* LogHandler::getErrorStr() { return m_errorStr; } void LogHandler::setErrorStr(char* str) { m_errorStr= str; } bool LogHandler::parseParams(const BaseString &_params) { Vector<BaseString> v_args; Loading @@ -165,10 +179,19 @@ LogHandler::parseParams(const BaseString &_params) { for(size_t i=0; i < v_args.size(); i++) { Vector<BaseString> v_param_value; if(v_args[i].split(v_param_value, "=", 2) != 2) { ret = false; else if (!setParam(v_param_value[0], v_param_value[1])) setErrorStr("Can't find key=value pair."); } else { v_param_value[0].trim(" \t"); if (!setParam(v_param_value[0], v_param_value[1])) { ret = false; } } } if(!checkParams()) ret = false; Loading
ndb/src/common/logger/Logger.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ Logger::addHandler(LogHandler* pHandler) } bool Logger::addHandler(const BaseString &logstring) { Logger::addHandler(const BaseString &logstring, int *err, int len, char* errStr) { size_t i; Vector<BaseString> logdest; Vector<LogHandler *>loghandlers; Loading Loading @@ -200,9 +200,18 @@ Logger::addHandler(const BaseString &logstring) { handler = new ConsoleLogHandler(); if(handler == NULL) { snprintf(errStr,len,"Could not create log destination: %s", logdest[i].c_str()); DBUG_RETURN(false); } if(!handler->parseParams(params)) { *err= handler->getErrorCode(); if(handler->getErrorStr()) strncpy(errStr, handler->getErrorStr(), len); DBUG_RETURN(false); } loghandlers.push_back(handler); } Loading