LOGIF removed from readconnroute.c

This commit is contained in:
Johan Wikman
2015-11-17 10:02:59 +02:00
parent 41d26b5b73
commit fb443a9f92
2 changed files with 63 additions and 80 deletions

View File

@ -93,6 +93,9 @@ extern __thread log_info_t tls_log_info;
#define LOG_MAY_BE_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \ #define LOG_MAY_BE_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
log_ses_count[id] > 0) ? true : false) log_ses_count[id] > 0) ? true : false)
// TODO: Add this at a later stage.
#define MXS_LOG_PRIORITY_IS_ENABLED(priority) false
/** /**
* Execute the given command if specified log is enabled in general or * Execute the given command if specified log is enabled in general or
* if the log is enabled for the current session. * if the log is enabled for the current session.

View File

@ -171,9 +171,7 @@ version()
void void
ModuleInit() ModuleInit()
{ {
LOGIF(LM, (skygw_log_write( MXS_NOTICE("Initialise readconnroute router module %s.", version_str);
LOGFILE_MESSAGE,
"Initialise readconnroute router module %s.\n", version_str)));
spinlock_init(&instlock); spinlock_init(&instlock);
instances = NULL; instances = NULL;
} }
@ -261,11 +259,10 @@ char *weightby;
} }
if (total == 0) if (total == 0)
{ {
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, MXS_WARNING("Weighting Parameter for service '%s' "
"WARNING: Weighting Parameter for service '%s' "
"will be ignored as no servers have values " "will be ignored as no servers have values "
"for the parameter '%s'.\n", "for the parameter '%s'.\n",
service->name, weightby))); service->name, weightby);
} }
else else
{ {
@ -280,14 +277,12 @@ char *weightby;
backend->weight = perc; backend->weight = perc;
if (perc == 0) if (perc == 0)
{ {
LOGIF(LE, (skygw_log_write( MXS_ERROR("Server '%s' has no value "
LOGFILE_ERROR,
"Server '%s' has no value "
"for weighting parameter '%s', " "for weighting parameter '%s', "
"no queries will be routed to " "no queries will be routed to "
"this server.\n", "this server.\n",
inst->servers[n]->server->unique_name, inst->servers[n]->server->unique_name,
weightby))); weightby);
} }
} }
@ -330,13 +325,11 @@ char *weightby;
} }
else else
{ {
LOGIF(LM, (skygw_log_write( MXS_WARNING("Unsupported router "
LOGFILE_MESSAGE,
"* Warning : Unsupported router "
"option \'%s\' for readconnroute. " "option \'%s\' for readconnroute. "
"Expected router options are " "Expected router options are "
"[slave|master|synced|ndb]", "[slave|master|synced|ndb]",
options[i]))); options[i]);
} }
} }
} }
@ -375,13 +368,11 @@ BACKEND *candidate = NULL;
int i; int i;
BACKEND *master_host = NULL; BACKEND *master_host = NULL;
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [newSession] new router session with session "
LOGFILE_DEBUG,
"%lu [newSession] new router session with session "
"%p, and inst %p.", "%p, and inst %p.",
pthread_self(), pthread_self(),
session, session,
inst))); inst);
client_rses = (ROUTER_CLIENT_SES *)calloc(1, sizeof(ROUTER_CLIENT_SES)); client_rses = (ROUTER_CLIENT_SES *)calloc(1, sizeof(ROUTER_CLIENT_SES));
@ -420,16 +411,14 @@ BACKEND *master_host = NULL;
*/ */
for (i = 0; inst->servers[i]; i++) { for (i = 0; inst->servers[i]; i++) {
if(inst->servers[i]) { if(inst->servers[i]) {
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [newSession] Examine server in port %d with "
LOGFILE_DEBUG,
"%lu [newSession] Examine server in port %d with "
"%d connections. Status is %s, " "%d connections. Status is %s, "
"inst->bitvalue is %d", "inst->bitvalue is %d",
pthread_self(), pthread_self(),
inst->servers[i]->server->port, inst->servers[i]->server->port,
inst->servers[i]->current_connection_count, inst->servers[i]->current_connection_count,
STRSRVSTATUS(inst->servers[i]->server), STRSRVSTATUS(inst->servers[i]->server),
inst->bitmask))); inst->bitmask);
} }
if (SERVER_IN_MAINT(inst->servers[i]->server)) if (SERVER_IN_MAINT(inst->servers[i]->server))
@ -512,11 +501,9 @@ BACKEND *master_host = NULL;
if (master_host) { if (master_host) {
candidate = master_host; candidate = master_host;
} else { } else {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to create new routing session. "
LOGFILE_ERROR,
"Error : Failed to create new routing session. "
"Couldn't find eligible candidate server. Freeing " "Couldn't find eligible candidate server. Freeing "
"allocated resources."))); "allocated resources.");
free(client_rses); free(client_rses);
return NULL; return NULL;
} }
@ -530,13 +517,11 @@ BACKEND *master_host = NULL;
*/ */
atomic_add(&candidate->current_connection_count, 1); atomic_add(&candidate->current_connection_count, 1);
client_rses->backend = candidate; client_rses->backend = candidate;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [newSession] Selected server in port %d. "
LOGFILE_DEBUG,
"%lu [newSession] Selected server in port %d. "
"Connections : %d\n", "Connections : %d\n",
pthread_self(), pthread_self(),
candidate->server->port, candidate->server->port,
candidate->current_connection_count))); candidate->current_connection_count);
/* /*
* Open a backend connection, putting the DCB for this * Open a backend connection, putting the DCB for this
@ -568,9 +553,7 @@ BACKEND *master_host = NULL;
CHK_CLIENT_RSES(client_rses); CHK_CLIENT_RSES(client_rses);
skygw_log_write( MXS_INFO("Readconnroute: New session for server %s. "
LOGFILE_TRACE,
"Readconnroute: New session for server %s. "
"Connections : %d", "Connections : %d",
candidate->server->unique_name, candidate->server->unique_name,
candidate->current_connection_count); candidate->current_connection_count);
@ -623,15 +606,13 @@ static void freeSession(
} }
spinlock_release(&router->lock); spinlock_release(&router->lock);
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [freeSession] Unlinked router_client_session %p from "
LOGFILE_DEBUG,
"%lu [freeSession] Unlinked router_client_session %p from "
"router %p and from server on port %d. Connections : %d. ", "router %p and from server on port %d. Connections : %d. ",
pthread_self(), pthread_self(),
router_cli_ses, router_cli_ses,
router, router,
router_cli_ses->backend->server->port, router_cli_ses->backend->server->port,
prev_val-1))); prev_val-1);
free(router_cli_ses); free(router_cli_ses);
} }
@ -721,11 +702,9 @@ routeQuery(ROUTER *instance, void *router_session, GWBUF *queue)
if (rses_is_closed || backend_dcb == NULL || if (rses_is_closed || backend_dcb == NULL ||
SERVER_IS_DOWN(router_cli_ses->backend->server)) SERVER_IS_DOWN(router_cli_ses->backend->server))
{ {
LOGIF(LT, (skygw_log_write( MXS_ERROR("Failed to route MySQL command %d to backend "
LOGFILE_TRACE|LOGFILE_ERROR,
"Error : Failed to route MySQL command %d to backend "
"server.%s", "server.%s",
mysql_command,rses_is_closed ? " Session is closed." : ""))); mysql_command,rses_is_closed ? " Session is closed." : "");
rc = 0; rc = 0;
while((queue = GWBUF_CONSUME_ALL(queue)) != NULL); while((queue = GWBUF_CONSUME_ALL(queue)) != NULL);
goto return_rc; goto return_rc;
@ -743,19 +722,20 @@ routeQuery(ROUTER *instance, void *router_session, GWBUF *queue)
queue); queue);
break; break;
case MYSQL_COM_QUERY: case MYSQL_COM_QUERY:
LOGIF(LOGFILE_TRACE,(trc = modutil_get_SQL(queue))); if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
{
trc = modutil_get_SQL(queue);
}
default: default:
rc = backend_dcb->func.write(backend_dcb, queue); rc = backend_dcb->func.write(backend_dcb, queue);
break; break;
} }
LOGIF(LOGFILE_TRACE,skygw_log_write( MXS_INFO("Routed [%s] to '%s'%s%s",
LOGFILE_DEBUG|LOGFILE_TRACE,
"Routed [%s] to '%s'%s%s",
STRPACKETTYPE(mysql_command), STRPACKETTYPE(mysql_command),
backend_dcb->server->unique_name, backend_dcb->server->unique_name,
trc?": ":".", trc?": ":".",
trc?trc:"")); trc?trc:"");
free(trc); free(trc);
return_rc: return_rc:
return rc; return rc;