Commit 08ffa298 authored by unknown's avatar unknown

Moved event category match functionality into mgmapi

Removed grep introduced bogus mgm call


BitKeeper/deleted/.del-LogLevel.cpp~314a6bada2df40a8:
  Delete: ndb/src/common/debugger/LogLevel.cpp
ndb/include/debugger/EventLogger.hpp:
  Removed match functionality and put into mgmapi
ndb/include/kernel/LogLevel.hpp:
  Update LogLevel
ndb/include/mgmapi/mgmapi_config_parameters.h:
  fix parameter
ndb/src/common/debugger/EventLogger.cpp:
  Removed match functionality and put into mgmapi
ndb/src/common/debugger/Makefile.am:
  removed LogLevel.cpp
ndb/src/cw/cpcd/APIService.cpp:
  compiler warning
ndb/src/cw/cpcd/CPCD.cpp:
  compiler warning
ndb/src/cw/cpcd/CPCD.hpp:
  compiler warning
ndb/src/cw/cpcd/main.cpp:
  compiler warning
ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp:
  Changed name of config parameter
ndb/src/kernel/vm/Configuration.cpp:
  Changed name of config parameter
parent 3bfae53b
......@@ -33,39 +33,6 @@ public:
*/
LogLevel m_logLevel;
/**
* Find a category matching the string
*
* @param str string to match.
* @param cat the event category.
* @param exactMatch only do exact matching.
*
* @return TRUE if match is found, then cat is modified
* FALSE if match is not found
*/
static bool matchEventCategory(const char * str,
LogLevel::EventCategory * cat,
bool exactMatch = false);
/**
* Returns category name or NULL if not found.
*
* @param cat the event category.
* @return category name.
*/
static const char * getEventCategoryName(LogLevel::EventCategory cat);
/**
* Specifies allowed event categories/log levels.
*/
struct EventCategoryName {
LogLevel::EventCategory category;
const char * name;
};
static const EventCategoryName eventCategoryNames[];
static const Uint32 noOfEventCategoryNames;
/**
* This matrix defines which event should be printed when
*
......
......@@ -46,76 +46,24 @@ public:
*/
LogLevel & operator= (const LogLevel &);
static const Uint32 MIN_LOGLEVEL_ID = CFG_LOGLEVEL_STARTUP;
enum EventCategory {
/**
* Events during all kind of startups
*/
llStartUp = CFG_LOGLEVEL_STARTUP - MIN_LOGLEVEL_ID,
/**
* Events during shutdown
*/
llShutdown = CFG_LOGLEVEL_SHUTDOWN - MIN_LOGLEVEL_ID,
/**
* Transaction statistics
* Job level
* TCP/IP speed
*/
llStatistic = CFG_LOGLEVEL_STATISTICS - MIN_LOGLEVEL_ID,
/**
* Checkpoints
*/
llCheckpoint = CFG_LOGLEVEL_CHECKPOINT - MIN_LOGLEVEL_ID,
/**
* Events during node restart
*/
llNodeRestart = CFG_LOGLEVEL_NODERESTART - MIN_LOGLEVEL_ID,
/**
* Events related to connection / communication
*/
llConnection = CFG_LOGLEVEL_CONNECTION - MIN_LOGLEVEL_ID,
/**
* Assorted event w.r.t unexpected happenings
*/
llError = CFG_LOGLEVEL_ERROR - MIN_LOGLEVEL_ID,
/**
* Assorted event w.r.t warning
*/
llWarning = CFG_LOGLEVEL_WARNING - MIN_LOGLEVEL_ID,
/**
* Assorted event w.r.t information
*/
llInfo = CFG_LOGLEVEL_INFO - MIN_LOGLEVEL_ID,
/**
* Events related to global replication
*/
llGrep = CFG_LOGLEVEL_GREP - MIN_LOGLEVEL_ID
};
struct LogLevelCategoryName {
const char* name;
llStartUp = CFG_LOGLEVEL_STARTUP - CFG_MIN_LOGLEVEL,
llShutdown = CFG_LOGLEVEL_SHUTDOWN - CFG_MIN_LOGLEVEL,
llStatistic = CFG_LOGLEVEL_STATISTICS - CFG_MIN_LOGLEVEL,
llCheckpoint = CFG_LOGLEVEL_CHECKPOINT - CFG_MIN_LOGLEVEL,
llNodeRestart = CFG_LOGLEVEL_NODERESTART - CFG_MIN_LOGLEVEL,
llConnection = CFG_LOGLEVEL_CONNECTION - CFG_MIN_LOGLEVEL,
llInfo = CFG_LOGLEVEL_INFO - CFG_MIN_LOGLEVEL,
llWarning = CFG_LOGLEVEL_WARNING - CFG_MIN_LOGLEVEL,
llError = CFG_LOGLEVEL_ERROR - CFG_MIN_LOGLEVEL,
llGrep = CFG_LOGLEVEL_GREP - CFG_MIN_LOGLEVEL,
llDebug = CFG_LOGLEVEL_DEBUG - CFG_MIN_LOGLEVEL,
};
/**
* Log/event level category names. Remember to update the names whenever
* a new category is added.
*/
static const LogLevelCategoryName LOGLEVEL_CATEGORY_NAME[];
/**
* No of categories
*/
#define _LOGLEVEL_CATEGORIES 10
#define _LOGLEVEL_CATEGORIES (CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1);
static const Uint32 LOGLEVEL_CATEGORIES = _LOGLEVEL_CATEGORIES;
void clear();
......
......@@ -254,17 +254,32 @@ extern "C" {
* Log categories
*/
enum ndb_mgm_event_category {
NDB_MGM_EVENT_CATEGORY_STARTUP, ///< Events during all kinds
///< of startups
NDB_MGM_EVENT_CATEGORY_SHUTDOWN, ///< Events during shutdown
NDB_MGM_EVENT_CATEGORY_STATISTIC, ///< Transaction statistics
///< (Job level, TCP/IP speed)
NDB_MGM_EVENT_CATEGORY_CHECKPOINT, ///< Checkpoints
NDB_MGM_EVENT_CATEGORY_NODE_RESTART, ///< Events during node restart
NDB_MGM_EVENT_CATEGORY_CONNECTION, ///< Events related to connection
///< and communication
NDB_MGM_EVENT_CATEGORY_ERROR ///< Assorted event w.r.t.
///< unexpected happenings
NDB_MGM_ILLEGAL_EVENT_CATEGORY = -1, ///< Invalid
/**
* Events during all kinds of startups
*/
NDB_MGM_EVENT_CATEGORY_STARTUP = CFG_LOGLEVEL_STARTUP,
/**
* Events during shutdown
*/
NDB_MGM_EVENT_CATEGORY_SHUTDOWN = CFG_LOGLEVEL_SHUTDOWN,
/**
* Transaction statistics (Job level, TCP/IP speed)
*/
NDB_MGM_EVENT_CATEGORY_STATISTIC = CFG_LOGLEVEL_STATISTICS,
NDB_MGM_EVENT_CATEGORY_CHECKPOINT = CFG_LOGLEVEL_CHECKPOINT,
NDB_MGM_EVENT_CATEGORY_NODE_RESTART = CFG_LOGLEVEL_NODERESTART,
NDB_MGM_EVENT_CATEGORY_CONNECTION = CFG_LOGLEVEL_CONNECTION,
NDB_MGM_EVENT_CATEGORY_DEBUG = CFG_LOGLEVEL_DEBUG,
NDB_MGM_EVENT_CATEGORY_INFO = CFG_LOGLEVEL_INFO,
NDB_MGM_EVENT_CATEGORY_WARNING = CFG_LOGLEVEL_WARNING,
NDB_MGM_EVENT_CATEGORY_ERROR = CFG_LOGLEVEL_ERROR,
NDB_MGM_EVENT_CATEGORY_GREP = CFG_LOGLEVEL_GREP,
NDB_MGM_MIN_EVENT_CATEGORY = CFG_MIN_LOGLEVEL,
NDB_MGM_MAX_EVENT_CATEGORY = CFG_MAX_LOGLEVEL
};
/***************************************************************************/
......@@ -402,6 +417,9 @@ extern "C" {
*/
const char * ndb_mgm_get_node_status_string(enum ndb_mgm_node_status status);
ndb_mgm_event_category ndb_mgm_match_event_category(const char *);
const char * ndb_mgm_get_event_category_string(enum ndb_mgm_event_category);
/** @} *********************************************************************/
/**
* @name Functions: State of cluster
......@@ -562,8 +580,7 @@ extern "C" {
*/
int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle,
int nodeId,
/*enum ndb_mgm_event_category category*/
char * category,
enum ndb_mgm_event_category category,
int level,
struct ndb_mgm_reply* reply);
......@@ -579,8 +596,7 @@ extern "C" {
*/
int ndb_mgm_set_loglevel_node(NdbMgmHandle handle,
int nodeId,
/*enum ndb_mgm_event_category category*/
char * category,
enum ndb_mgm_event_category category,
int level,
struct ndb_mgm_reply* reply);
......
#ifndef MGMAPI_CONFIG_PARAMTERS_H
#define MGMAPI_CONFIG_PARAMTERS_H
#define CFG_SYS_NAME 3
#define CFG_SYS_PRIMARY_MGM_NODE 1
#define CFG_SYS_CONFIG_GENERATION 2
......@@ -64,16 +63,6 @@
#define CFG_DB_BACKUP_LOG_BUFFER_MEM 135
#define CFG_DB_BACKUP_WRITE_SIZE 136
#define CFG_LOGLEVEL_STARTUP 137
#define CFG_LOGLEVEL_SHUTDOWN 138
#define CFG_LOGLEVEL_STATISTICS 139
#define CFG_LOGLEVEL_CHECKPOINT 140
#define CFG_LOGLEVEL_NODERESTART 141
#define CFG_LOGLEVEL_CONNECTION 142
#define CFG_LOGLEVEL_INFO 143
#define CFG_LOGLEVEL_WARNING 144
#define CFG_LOGLEVEL_ERROR 145
#define CFG_LOGLEVEL_GREP 146
#define CFG_LOG_DESTINATION 147
#define CFG_DB_DISCLESS 148
......@@ -95,6 +84,20 @@
#define CFG_NODE_ARBIT_RANK 200
#define CFG_NODE_ARBIT_DELAY 201
#define CFG_MIN_LOGLEVEL 250
#define CFG_LOGLEVEL_STARTUP 250
#define CFG_LOGLEVEL_SHUTDOWN 251
#define CFG_LOGLEVEL_STATISTICS 252
#define CFG_LOGLEVEL_CHECKPOINT 253
#define CFG_LOGLEVEL_NODERESTART 254
#define CFG_LOGLEVEL_CONNECTION 255
#define CFG_LOGLEVEL_INFO 256
#define CFG_LOGLEVEL_WARNING 257
#define CFG_LOGLEVEL_ERROR 258
#define CFG_LOGLEVEL_GREP 259
#define CFG_LOGLEVEL_DEBUG 260
#define CFG_MAX_LOGLEVEL 260
#define CFG_MGM_PORT 300
#define CFG_CONNECTION_NODE_1 400
......
......@@ -113,26 +113,6 @@ const EventLoggerBase::EventRepLogLevelMatrix EventLoggerBase::matrix[] = {
const Uint32 EventLoggerBase::matrixSize = sizeof(EventLoggerBase::matrix)/
sizeof(EventRepLogLevelMatrix);
/**
* Specifies allowed event categories/log levels that can be set from
* the Management API/interactive shell.
*/
const EventLoggerBase::EventCategoryName
EventLoggerBase::eventCategoryNames[] = {
{ LogLevel::llStartUp, "STARTUP" },
{ LogLevel::llStatistic, "STATISTICS" },
{ LogLevel::llCheckpoint, "CHECKPOINT" },
{ LogLevel::llNodeRestart, "NODERESTART" },
{ LogLevel::llConnection, "CONNECTION" },
{ LogLevel::llInfo, "INFO" },
{ LogLevel::llGrep, "GREP" }
};
const Uint32
EventLoggerBase::noOfEventCategoryNames =
sizeof(EventLoggerBase::eventCategoryNames)/
sizeof(EventLoggerBase::EventCategoryName);
const char*
EventLogger::getText(char * m_text, size_t m_text_len,
int type,
......@@ -1287,41 +1267,6 @@ EventLogger::getText(char * m_text, size_t m_text_len,
return m_text;
}
bool
EventLoggerBase::matchEventCategory(const char * str,
LogLevel::EventCategory * cat,
bool exactMatch){
unsigned i;
if(cat == 0 || str == 0)
return false;
char * tmp = strdup(str);
for(i = 0; i<strlen(tmp); i++)
tmp[i] = toupper(tmp[i]);
for(i = 0; i<noOfEventCategoryNames; i++){
if(strcmp(tmp, eventCategoryNames[i].name) == 0){
* cat = eventCategoryNames[i].category;
free(tmp);
return true;
}
}
free(tmp);
return false;
}
const char *
EventLoggerBase::getEventCategoryName(LogLevel::EventCategory cat){
for(unsigned i = 0; i<noOfEventCategoryNames; i++){
if(cat == eventCategoryNames[i].category){
return eventCategoryNames[i].name;
}
}
return 0;
}
EventLogger::EventLogger() : m_filterLevel(15)
{
setCategory("EventLogger");
......
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <LogLevel.hpp>
const LogLevel::LogLevelCategoryName LogLevel::LOGLEVEL_CATEGORY_NAME[] = {
{ "LogLevelStartup" },
{ "LogLevelShutdown" },
{ "LogLevelStatistic" },
{ "LogLevelCheckpoint" },
{ "LogLevelNodeRestart" },
{ "LogLevelConnection" },
{ "LogLevelError" },
{ "LogLevelWarning" },
{ "LogLevelInfo" },
{ "LogLevelGrep" }
};
......@@ -2,7 +2,7 @@ SUBDIRS = signaldata
noinst_LTLIBRARIES = libtrace.la
libtrace_la_SOURCES = SignalLoggerManager.cpp DebuggerNames.cpp BlockNames.cpp LogLevel.cpp EventLogger.cpp GrepError.cpp
libtrace_la_SOURCES = SignalLoggerManager.cpp DebuggerNames.cpp BlockNames.cpp EventLogger.cpp GrepError.cpp
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_kernel.mk.am
......
......@@ -47,7 +47,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
fun, \
desc }
desc, 0 }
#define CPCD_ARG(name, type, opt, desc) \
{ name, \
......@@ -58,7 +58,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
0, \
desc }
desc, 0 }
#define CPCD_ARG2(name, type, opt, min, max, desc) \
{ name, \
......@@ -69,7 +69,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
min, max, \
0, \
desc }
desc, 0 }
#define CPCD_END() \
{ 0, \
......@@ -80,7 +80,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
0, \
0 }
0, 0 }
#define CPCD_CMD_ALIAS(name, realName, fun) \
{ name, \
......@@ -91,7 +91,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
0, \
0 }
0, 0 }
#define CPCD_ARG_ALIAS(name, realName, fun) \
{ name, \
......@@ -102,7 +102,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
0, \
0 }
0, 0 }
const
ParserRow<CPCDAPISession> commands[] =
......
......@@ -378,7 +378,7 @@ CPCD::getProcessList() {
}
void
CPCD::RequestStatus::err(enum RequestStatusCode status, char *msg) {
CPCD::RequestStatus::err(enum RequestStatusCode status, const char *msg) {
m_status = status;
snprintf(m_errorstring, sizeof(m_errorstring), "%s", msg);
}
......
......@@ -91,7 +91,7 @@ public:
RequestStatus() { m_status = OK; m_errorstring[0] = '\0'; };
/** @brief Sets an errorcode and a printable message */
void err(enum RequestStatusCode, char *);
void err(enum RequestStatusCode, const char *);
/** @brief Returns the error message */
char *getErrMsg() { return m_errorstring; };
......
......@@ -28,12 +28,12 @@
#include "common.hpp"
static char *work_dir = CPCD_DEFAULT_WORK_DIR;
static const char *work_dir = CPCD_DEFAULT_WORK_DIR;
static int port = CPCD_DEFAULT_TCP_PORT;
static int use_syslog = 0;
static char *logfile = NULL;
static char *config_file = CPCD_DEFAULT_CONFIG_FILE;
static char *user = 0;
static const char *logfile = NULL;
static const char *config_file = CPCD_DEFAULT_CONFIG_FILE;
static const char *user = 0;
static struct getargs args[] = {
{ "work-dir", 'w', arg_string, &work_dir,
......
......@@ -97,7 +97,7 @@ Cmvmi::Cmvmi(const Configuration & conf) :
const ndb_mgm_configuration_iterator * db = theConfig.getOwnConfigIterator();
for(unsigned j = 0; j<LogLevel::LOGLEVEL_CATEGORIES; j++){
Uint32 logLevel;
if(!ndb_mgm_get_int_parameter(db, LogLevel::MIN_LOGLEVEL_ID+j, &logLevel)){
if(!ndb_mgm_get_int_parameter(db, CFG_MIN_LOGLEVEL+j, &logLevel)){
clogLevel.setLogLevel((LogLevel::EventCategory)j,
logLevel);
}
......
......@@ -503,7 +503,7 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){
for(unsigned j = 0; j<LogLevel::LOGLEVEL_CATEGORIES; j++){
Uint32 tmp;
if(!ndb_mgm_get_int_parameter(&db, LogLevel::MIN_LOGLEVEL_ID+j, &tmp)){
if(!ndb_mgm_get_int_parameter(&db, CFG_MIN_LOGLEVEL+j, &tmp)){
m_logLevel->setLogLevel((LogLevel::EventCategory)j, tmp);
}
}
......
......@@ -954,13 +954,51 @@ struct ndb_mgm_event_categories
{
const char* name;
enum ndb_mgm_event_category category;
} categories[] = {
{ "STARTUP", NDB_MGM_EVENT_CATEGORY_STARTUP },
{ "SHUTDOWN", NDB_MGM_EVENT_CATEGORY_SHUTDOWN },
{ "STATISTICS", NDB_MGM_EVENT_CATEGORY_STATISTIC },
{ "NODERESTART", NDB_MGM_EVENT_CATEGORY_NODE_RESTART },
{ "CONNECTION", NDB_MGM_EVENT_CATEGORY_CONNECTION },
{ "CHECKPOINT", NDB_MGM_EVENT_CATEGORY_CHECKPOINT },
{ "DEBUG", NDB_MGM_EVENT_CATEGORY_DEBUG },
{ "INFO", NDB_MGM_EVENT_CATEGORY_INFO },
{ "ERROR", NDB_MGM_EVENT_CATEGORY_ERROR },
{ "GREP", NDB_MGM_EVENT_CATEGORY_GREP },
{ 0, NDB_MGM_ILLEGAL_EVENT_CATEGORY }
};
extern "C"
ndb_mgm_event_category
ndb_mgm_match_event_category(const char * status)
{
if(status == 0)
return NDB_MGM_ILLEGAL_EVENT_CATEGORY;
for(int i = 0; categories[i].name !=0 ; i++)
if(strcmp(status, categories[i].name) == 0)
return categories[i].category;
return NDB_MGM_ILLEGAL_EVENT_CATEGORY;
}
extern "C"
const char *
ndb_mgm_get_event_category_string(enum ndb_mgm_event_category status)
{
int i;
for(i = 0; categories[i].name != 0; i++)
if(categories[i].category == status)
return categories[i].name;
return 0;
}
extern "C"
int
ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle, int nodeId,
/*enum ndb_mgm_event_category*/
char * category, int level,
enum ndb_mgm_event_category cat,
int level,
struct ndb_mgm_reply* /*reply*/)
{
SET_ERROR(handle, NDB_MGM_NO_ERROR,
......@@ -975,7 +1013,7 @@ ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle, int nodeId,
Properties args;
args.put("node", nodeId);
args.put("category", category);
args.put("category", cat);
args.put("level", level);
const Properties *reply;
......@@ -997,8 +1035,8 @@ ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle, int nodeId,
extern "C"
int
ndb_mgm_set_loglevel_node(NdbMgmHandle handle, int nodeId,
/*enum ndb_mgm_event_category category*/
char * category, int level,
enum ndb_mgm_event_category category,
int level,
struct ndb_mgm_reply* /*reply*/)
{
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_set_loglevel_node");
......
......@@ -611,9 +611,9 @@ CommandInterpreter::executeHelp(char* parameters)
<< endl;
ndbout << "<category> = ";
for(Uint32 i = 0; i<EventLogger::noOfEventCategoryNames; i++){
ndbout << EventLogger::eventCategoryNames[i].name;
if (i < EventLogger::noOfEventCategoryNames - 1) {
for(int i = 0; i<CFG_MIN_LOGLEVEL; i++){
ndbout << ndb_mgm_get_event_category_string((ndb_mgm_event_category)i);
if (i < CFG_MIN_LOGLEVEL - 1) {
ndbout << " | ";
}
}
......@@ -1247,52 +1247,37 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters,
{
connect();
(void) all;
(void) parameters;
SetLogLevelOrd logLevel; logLevel.clear();
LogLevel::EventCategory cat;
int level;
if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) {
for(Uint32 i = 0; i<EventLogger::noOfEventCategoryNames; i++)
logLevel.setLogLevel(EventLogger::eventCategoryNames[i].category, 7);
} else {
char * tmpString = strdup(parameters);
char * tmpPtr = 0;
char * item = strtok_r(tmpString, ", ", &tmpPtr);
while(item != NULL){
char categoryTxt[255];
const int m = sscanf(item, "%[^=]=%d", categoryTxt, &level);
if(m != 2){
free(tmpString);
ndbout << "Invalid loglevel specification category=level" << endl;
BaseString tmp(parameters);
Vector<BaseString> spec;
tmp.split(spec, "=");
if(spec.size() != 2){
ndbout << "Invalid loglevel specification: " << parameters << endl;
return;
}
if(!EventLogger::matchEventCategory(categoryTxt,
&cat)){
ndbout << "Invalid loglevel specification, unknown category: "
<< categoryTxt << endl;
free(tmpString);
return ;
spec[0].trim().ndb_toupper();
int category = ndb_mgm_match_event_category(spec[0].c_str());
if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){
category = atoi(spec[0].c_str());
if(category < NDB_MGM_MIN_EVENT_CATEGORY ||
category > NDB_MGM_MAX_EVENT_CATEGORY){
ndbout << "Unknown category: \"" << spec[0].c_str() << "\"" << endl;
return;
}
if(level < 0 || level > 15){
ndbout << "Invalid loglevel specification row, level 0-15" << endl;
free(tmpString);
return ;
}
logLevel.setLogLevel(cat, level);
item = strtok_r(NULL, ", ", &tmpPtr);
}
free(tmpString);
int level = atoi(spec[1].c_str());
if(level < 0 || level > 15){
ndbout << "Invalid level: " << spec[1].c_str() << endl;
return;
}
struct ndb_mgm_reply reply;
int result;
result = ndb_mgm_set_loglevel_node(m_mgmsrv,
processId, // fast fix - pekka
(char*)EventLogger::getEventCategoryName(cat),
processId,
(ndb_mgm_event_category)category,
level,
&reply);
......@@ -1633,52 +1618,39 @@ CommandInterpreter::executeEventReporting(int processId,
bool all)
{
connect();
SetLogLevelOrd logLevel; logLevel.clear();
char categoryTxt[255];
int level;
LogLevel::EventCategory cat;
if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) {
for(Uint32 i = 0; i<EventLogger::noOfEventCategoryNames; i++)
logLevel.setLogLevel(EventLogger::eventCategoryNames[i].category, 7);
} else {
char * tmpString = strdup(parameters);
char * tmpPtr = 0;
char * item = strtok_r(tmpString, ", ", &tmpPtr);
while(item != NULL){
const int m = sscanf(item, "%[^=]=%d", categoryTxt, &level);
if(m != 2){
free(tmpString);
ndbout << "Invalid loglevel specification category=level" << endl;
BaseString tmp(parameters);
Vector<BaseString> spec;
tmp.split(spec, "=");
if(spec.size() != 2){
ndbout << "Invalid loglevel specification: " << parameters << endl;
return;
}
if(!EventLogger::matchEventCategory(categoryTxt,
&cat)){
ndbout << "Invalid loglevel specification, unknown category: "
<< categoryTxt << endl;
free(tmpString);
return ;
spec[0].trim().ndb_toupper();
int category = ndb_mgm_match_event_category(spec[0].c_str());
if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){
category = atoi(spec[0].c_str());
if(category < NDB_MGM_MIN_EVENT_CATEGORY ||
category > NDB_MGM_MAX_EVENT_CATEGORY){
ndbout << "Unknown category: \"" << spec[0].c_str() << "\"" << endl;
return;
}
if(level < 0 || level > 15){
ndbout << "Invalid loglevel specification row, level 0-15" << endl;
free(tmpString);
return ;
}
logLevel.setLogLevel(cat, level);
item = strtok_r(NULL, ", ", &tmpPtr);
}
free(tmpString);
int level = atoi(spec[1].c_str());
if(level < 0 || level > 15){
ndbout << "Invalid level: " << spec[1].c_str() << endl;
return;
}
struct ndb_mgm_reply reply;
int result;
result =
ndb_mgm_set_loglevel_clusterlog(m_mgmsrv,
result = ndb_mgm_set_loglevel_clusterlog(m_mgmsrv,
processId, // fast fix - pekka
(char*)
EventLogger::getEventCategoryName(cat),
(ndb_mgm_event_category)category,
level,
&reply);
......
......@@ -52,7 +52,7 @@ static const char* helpTexts[] = {
"{<id>|ALL} CLUSTERLOG {<category>=<level>}+ Set log level for cluster log",
"QUIT Quit management server",
};
static const int noOfHelpTexts = sizeof(helpTexts)/sizeof(const char*);
static const unsigned noOfHelpTexts = sizeof(helpTexts)/sizeof(const char*);
static const char* helpTextShow =
"SHOW prints NDB Cluster information\n\n"
......@@ -389,9 +389,9 @@ void CommandInterpreter::executeHelp(char* parameters) {
<< endl;
ndbout << "<category> = ";
for(i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++){
ndbout << EventLoggerBase::eventCategoryNames[i].name;
if (i < EventLoggerBase::noOfEventCategoryNames - 1) {
for(i = 0; i<CFG_MIN_LOGLEVEL; i++){
ndbout << ndb_mgm_get_event_category_string((ndb_mgm_event_category)i);
if (i < CFG_MIN_LOGLEVEL - 1) {
ndbout << " | ";
}
}
......
......@@ -611,7 +611,7 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
{
MgmStatService::StatListener se;
se.m_socket = -1;
for(size_t t = 0; t<_LOGLEVEL_CATEGORIES; t++)
for(size_t t = 0; t<LogLevel::LOGLEVEL_CATEGORIES; t++)
se.m_logLevel.setLogLevel((LogLevel::EventCategory)t, 7);
se.m_logLevel.setLogLevel(LogLevel::llError, 15);
m_statisticsListner.m_clients.push_back(se);
......
......@@ -763,12 +763,12 @@ MgmApiSession::bye(Parser<MgmApiSession>::Context &,
void
MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
Properties const &args) {
Uint32 node, level;
BaseString categoryName, errorString;
Uint32 node, level, category;
BaseString errorString;
SetLogLevelOrd logLevel;
int result;
args.get("node", &node);
args.get("category", categoryName);
args.get("category", &category);
args.get("level", &level);
/* XXX should use constants for this value */
......@@ -777,14 +777,6 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
goto error;
}
categoryName.ndb_toupper();
LogLevel::EventCategory category;
if(!EventLogger::matchEventCategory(categoryName.c_str(), &category)) {
errorString.assign("Unknown category");
goto error;
}
EventSubscribeReq req;
req.blockRef = 0;
req.noOfEntries = 1;
......@@ -796,7 +788,7 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
m_output->println("result: Ok");
m_output->println("");
return;
error:
error:
m_output->println("set cluster loglevel reply");
m_output->println("result: %s", errorString.c_str());
m_output->println("");
......@@ -805,13 +797,13 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
void
MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &,
Properties const &args) {
Uint32 node = 0, level = 0;
BaseString categoryName, errorString;
Uint32 node = 0, level = 0, category;
BaseString errorString;
SetLogLevelOrd logLevel;
int result;
logLevel.clear();
args.get("node", &node);
args.get("category", categoryName);
args.get("category", &category);
args.get("level", &level);
/* XXX should use constants for this value */
......@@ -820,14 +812,6 @@ MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &,
goto error;
}
categoryName.ndb_toupper();
LogLevel::EventCategory category;
if(!EventLogger::matchEventCategory(categoryName.c_str(), &category)) {
errorString.assign("Unknown category");
goto error;
}
EventSubscribeReq req;
req.blockRef = node;
req.noOfEntries = 1;
......@@ -1259,7 +1243,7 @@ NdbOut&
operator<<(NdbOut& out, const LogLevel & ll)
{
out << "[LogLevel: ";
for(size_t i = 0; i<_LOGLEVEL_CATEGORIES; i++)
for(size_t i = 0; i<LogLevel::LOGLEVEL_CATEGORIES; i++)
out << ll.getLogLevel((LogLevel::EventCategory)i) << " ";
out << "]";
}
......@@ -1391,15 +1375,17 @@ MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx,
goto done;
}
spec[0].trim();
spec[0].ndb_toupper();
LogLevel::EventCategory category;
if(!EventLogger::matchEventCategory(spec[0].c_str(), &category)) {
spec[0].trim().ndb_toupper();
int category = ndb_mgm_match_event_category(spec[0].c_str());
if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){
category = atoi(spec[0].c_str());
if(category < NDB_MGM_MIN_EVENT_CATEGORY ||
category > NDB_MGM_MAX_EVENT_CATEGORY){
msg.appfmt("Unknown category: >%s<", spec[0].c_str());
result = -1;
goto done;
}
}
int level = atoi(spec[1].c_str());
if(level < 0 || level > 15){
......@@ -1407,7 +1393,7 @@ MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx,
result = -1;
goto done;
}
le.m_logLevel.setLogLevel(category, level);
le.m_logLevel.setLogLevel((LogLevel::EventCategory)category, level);
}
if(list.size() == 0){
......
......@@ -16,5 +16,3 @@ fi
echo "NDBT_ProgramExit: Failed"
exit 1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment