Merge branch 'develop' of https://github.com/mariadb-corporation/MaxScale into develop
This commit is contained in:
commit
2c87edfe27
@ -2552,6 +2552,7 @@ static bool logfile_init(
|
||||
logfile_free_memory(logfile);
|
||||
goto return_with_succp;
|
||||
}
|
||||
#if defined(SS_DEBUG)
|
||||
if (store_shmem)
|
||||
{
|
||||
fprintf(stderr, "%s\t: %s->%s\n",
|
||||
@ -2565,6 +2566,7 @@ static bool logfile_init(
|
||||
STRLOGNAME(logfile_id),
|
||||
logfile->lf_full_file_name);
|
||||
}
|
||||
#endif
|
||||
succp = true;
|
||||
logfile->lf_state = RUN;
|
||||
CHK_LOGFILE(logfile);
|
||||
|
@ -390,7 +390,11 @@ static bool file_write_header(
|
||||
ts1.tv_sec = 0;
|
||||
ts1.tv_nsec = DISKWRITE_LATENCY*1000000;
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(SS_DEBUG)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if ((t = (time_t *)malloc(sizeof(time_t))) == NULL) {
|
||||
goto return_succp;
|
||||
}
|
||||
@ -1185,8 +1189,12 @@ int main(int argc, char **argv)
|
||||
if (!daemon_mode)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Info : MaxScale will be run in the terminal process.\n See "
|
||||
"Info : MaxScale will be run in the terminal process.\n");
|
||||
#if defined(SS_DEBUG)
|
||||
fprintf(stderr,
|
||||
"\tSee "
|
||||
"the log from the following log files : \n\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1198,11 +1206,11 @@ int main(int argc, char **argv)
|
||||
int eno = 0;
|
||||
char* fprerr = "Failed to initialize set the signal "
|
||||
"set for MaxScale. Exiting.";
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
fprintf(stderr,
|
||||
"Info : MaxScale will be run in a daemon process.\n\tSee "
|
||||
"the log from the following log files : \n\n");
|
||||
|
||||
#endif
|
||||
r = sigfillset(&sigset);
|
||||
|
||||
if (r != 0)
|
||||
@ -1553,9 +1561,11 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr,
|
||||
"Home directory : %s"
|
||||
"\nConfiguration file : %s"
|
||||
"\nLog directory : %s/log"
|
||||
"\nData directory : %s\n\n",
|
||||
home_dir,
|
||||
cnf_file_path,
|
||||
home_dir,
|
||||
datadir);
|
||||
}
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
@ -1566,6 +1576,10 @@ int main(int argc, char **argv)
|
||||
LOGFILE_MESSAGE,
|
||||
"Data directory : %s",
|
||||
datadir)));
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Log directory : %s/log",
|
||||
home_dir)));
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Configuration file : %s",
|
||||
|
@ -572,7 +572,7 @@ SESSION *ptr;
|
||||
ptr = allSessions;
|
||||
while (ptr)
|
||||
{
|
||||
dcb_printf(dcb, "Session %p\n", ptr);
|
||||
dcb_printf(dcb, "Session %d (%p)\n",ptr->ses_id, ptr);
|
||||
dcb_printf(dcb, "\tState: %s\n", session_state(ptr->state));
|
||||
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
|
||||
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
|
||||
@ -598,7 +598,7 @@ dprintSession(DCB *dcb, SESSION *ptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
dcb_printf(dcb, "Session %p\n", ptr);
|
||||
dcb_printf(dcb, "Session %d (%p)\n",ptr->ses_id, ptr);
|
||||
dcb_printf(dcb, "\tState: %s\n", session_state(ptr->state));
|
||||
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
|
||||
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
|
||||
@ -853,3 +853,11 @@ session_getUser(SESSION *session)
|
||||
{
|
||||
return (session && session->client) ? session->client->user : NULL;
|
||||
}
|
||||
/**
|
||||
* Return the pointer to the list of all sessions.
|
||||
* @return Pointer to the list of all sessions.
|
||||
*/
|
||||
SESSION *get_all_sessions()
|
||||
{
|
||||
return allSessions;
|
||||
}
|
||||
|
@ -148,6 +148,7 @@ typedef struct session {
|
||||
((sess)->tail.clientReply)((sess)->tail.instance, \
|
||||
(sess)->tail.session, (buf))
|
||||
|
||||
SESSION *get_all_sessions();
|
||||
SESSION *session_alloc(struct service *, struct dcb *);
|
||||
bool session_free(SESSION *);
|
||||
int session_isvalid(SESSION *);
|
||||
|
@ -328,6 +328,8 @@ struct subcommand reloadoptions[] = {
|
||||
|
||||
static void enable_log_action(DCB *, char *);
|
||||
static void disable_log_action(DCB *, char *);
|
||||
static void enable_sess_log_action(DCB *dcb, char *arg1, char *arg2);
|
||||
static void disable_sess_log_action(DCB *dcb, char *arg1, char *arg2);
|
||||
static void enable_monitor_replication_heartbeat(DCB *dcb, MONITOR *monitor);
|
||||
static void disable_monitor_replication_heartbeat(DCB *dcb, MONITOR *monitor);
|
||||
static void enable_service_root(DCB *dcb, SERVICE *service);
|
||||
@ -362,6 +364,16 @@ struct subcommand enableoptions[] = {
|
||||
"Enable root access to a service, pass a service name to enable root access",
|
||||
"Enable root access to a service, pass a service name to enable root access",
|
||||
{ARG_TYPE_SERVICE, 0, 0}
|
||||
},
|
||||
{
|
||||
"seslog",
|
||||
2,
|
||||
enable_sess_log_action,
|
||||
"Enable Log options for a single session, options trace | error | "
|
||||
"message <session id> E.g. enable log message 123.",
|
||||
"Enable Log options for a single session, options trace | error | "
|
||||
"message <session id> E.g. enable log message 123.",
|
||||
{ARG_TYPE_STRING, ARG_TYPE_STRING, 0}
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
@ -374,6 +386,7 @@ struct subcommand enableoptions[] = {
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* * The subcommands of the disable command
|
||||
* */
|
||||
@ -396,6 +409,16 @@ struct subcommand disableoptions[] = {
|
||||
"E.g. disable log debug",
|
||||
{ARG_TYPE_STRING, 0, 0}
|
||||
},
|
||||
{
|
||||
"seslog",
|
||||
2,
|
||||
disable_sess_log_action,
|
||||
"Disable Log options for a single session, options trace | error | "
|
||||
"message <session id> E.g. disable log message 123.",
|
||||
"Disable Log options for a single session, options trace | error | "
|
||||
"message <session id> E.g. disable log message 123.",
|
||||
{ARG_TYPE_STRING, ARG_TYPE_STRING, 0}
|
||||
},
|
||||
{
|
||||
"root",
|
||||
1,
|
||||
@ -676,6 +699,7 @@ char *args[MAXARGS + 1];
|
||||
unsigned long arg1, arg2, arg3;
|
||||
int in_quotes = 0, escape_next = 0;
|
||||
char *ptr, *lptr;
|
||||
bool in_space = false;
|
||||
|
||||
args[0] = cli->cmdbuf;
|
||||
ptr = args[0];
|
||||
@ -687,6 +711,7 @@ char *ptr, *lptr;
|
||||
* the use of double quotes.
|
||||
* The array args contains the broken down words, one per index.
|
||||
*/
|
||||
|
||||
while (*ptr)
|
||||
{
|
||||
if (escape_next)
|
||||
@ -699,9 +724,15 @@ char *ptr, *lptr;
|
||||
escape_next = 1;
|
||||
ptr++;
|
||||
}
|
||||
else if (in_quotes == 0 && (*ptr == ' ' || *ptr == '\t' || *ptr == '\r' || *ptr == '\n'))
|
||||
else if (in_quotes == 0 && ((in_space = *ptr == ' ') || *ptr == '\t' || *ptr == '\r' || *ptr == '\n'))
|
||||
{
|
||||
|
||||
*lptr = 0;
|
||||
|
||||
if(!in_space){
|
||||
break;
|
||||
}
|
||||
|
||||
if (args[i] == ptr)
|
||||
args[i] = ptr + 1;
|
||||
else
|
||||
@ -1140,6 +1171,91 @@ disable_service_root(DCB *dcb, SERVICE *service)
|
||||
serviceEnableRootUser(service, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a log for a single session
|
||||
* @param session The session in question
|
||||
* @param dcb Client DCB
|
||||
* @param type Which log to enable
|
||||
*/
|
||||
static void enable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
|
||||
{
|
||||
logfile_id_t type;
|
||||
size_t id = 0;
|
||||
int max_len = strlen("message");
|
||||
SESSION* session = get_all_sessions();
|
||||
|
||||
ss_dassert(arg1 != NULL && arg2 != NULL && session != NULL);
|
||||
|
||||
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||
type = LOGFILE_DEBUG;
|
||||
} else if (strncmp(arg1, "trace", max_len) == 0) {
|
||||
type = LOGFILE_TRACE;
|
||||
} else if (strncmp(arg1, "error", max_len) == 0) {
|
||||
type = LOGFILE_ERROR;
|
||||
} else if (strncmp(arg1, "message", max_len) == 0) {
|
||||
type = LOGFILE_MESSAGE;
|
||||
} else {
|
||||
dcb_printf(dcb, "%s is not supported for enable log\n", arg1);
|
||||
return ;
|
||||
}
|
||||
|
||||
id = (size_t)strtol(arg2,0,0);
|
||||
|
||||
while(session)
|
||||
{
|
||||
if(session->ses_id == id)
|
||||
{
|
||||
session_enable_log(session,type);
|
||||
return;
|
||||
}
|
||||
session = session->next;
|
||||
}
|
||||
|
||||
dcb_printf(dcb, "Session not found: %s\n", arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables a log for a single session
|
||||
* @param session The session in question
|
||||
* @param dcb Client DCB
|
||||
* @param type Which log to disable
|
||||
*/
|
||||
static void disable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
|
||||
{
|
||||
logfile_id_t type;
|
||||
int id = 0;
|
||||
int max_len = strlen("message");
|
||||
SESSION* session = get_all_sessions();
|
||||
|
||||
ss_dassert(arg1 != NULL && arg2 != NULL && session != NULL);
|
||||
|
||||
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||
type = LOGFILE_DEBUG;
|
||||
} else if (strncmp(arg1, "trace", max_len) == 0) {
|
||||
type = LOGFILE_TRACE;
|
||||
} else if (strncmp(arg1, "error", max_len) == 0) {
|
||||
type = LOGFILE_ERROR;
|
||||
} else if (strncmp(arg1, "message", max_len) == 0) {
|
||||
type = LOGFILE_MESSAGE;
|
||||
} else {
|
||||
dcb_printf(dcb, "%s is not supported for disable log\n", arg1);
|
||||
return ;
|
||||
}
|
||||
|
||||
id = (size_t)strtol(arg2,0,0);
|
||||
|
||||
while(session)
|
||||
{
|
||||
if(session->ses_id == id)
|
||||
{
|
||||
session_disable_log(session,type);
|
||||
return;
|
||||
}
|
||||
session = session->next;
|
||||
}
|
||||
|
||||
dcb_printf(dcb, "Session not found: %s\n", arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The log enable action
|
||||
@ -1161,7 +1277,7 @@ static void enable_log_action(DCB *dcb, char *arg1) {
|
||||
dcb_printf(dcb, "%s is not supported for enable log\n", arg1);
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
skygw_log_enable(type);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user