Use RFC 3986 compliant addresses in log messages

When log messages are written with both address and port information, IPv6
addresses can cause confusion if the normal address:port formatting is
used. The RFC 3986 suggests that all IPv6 addresses are expressed as a
bracket enclosed address optionally followed by the port that is separate
from the address by a colon.

In practice, the "all interfaces" address and port number 3306 can be
written in IPv4 numbers-and-dots notation as 0.0.0.0:3306 and in IPv6
notation as [::]:3306. Using the latter format in log messages keeps the
output consistent with all types of addresses.

The details of the standard can be found at the following addresses:

     https://www.ietf.org/rfc/rfc3986.txt

     https://www.rfc-editor.org/std/std66.txt
This commit is contained in:
Markus Mäkelä
2017-03-29 23:30:34 +03:00
parent 32dca26c96
commit cbc1e864d9
23 changed files with 97 additions and 78 deletions

View File

@ -762,14 +762,14 @@ static void clientReply(MXS_ROUTER *instance,
{
bool succp;
MXS_INFO("Backend %s:%d processed reply and starts to execute active cursor.",
MXS_INFO("Backend [%s]:%d processed reply and starts to execute active cursor.",
bref->ref->server->name, bref->ref->server->port);
succp = execute_sescmd_in_backend(bref);
if (!succp)
{
MXS_INFO("Backend %s:%d failed to execute session command.",
MXS_INFO("Backend [%s]:%d failed to execute session command.",
bref->ref->server->name, bref->ref->server->port);
}
}
@ -1087,7 +1087,7 @@ int router_handle_state_switch(DCB *dcb, DCB_REASON reason, void *data)
goto return_rc;
}
MXS_DEBUG("%lu [router_handle_state_switch] %s %s:%d in state %s",
MXS_DEBUG("%lu [router_handle_state_switch] %s [%s]:%d in state %s",
pthread_self(), STRDCBREASON(reason), srv->name, srv->port,
STRSRVSTATUS(srv));
CHK_SESSION(((MXS_SESSION *)dcb->session));
@ -1318,7 +1318,7 @@ static void handleError(MXS_ROUTER *instance,
}
else if (!SERVER_IS_MASTER(srv) && !srv->master_err_is_logged)
{
MXS_ERROR("Server %s:%d lost the master status. Readwritesplit "
MXS_ERROR("Server [%s]:%d lost the master status. Readwritesplit "
"service can't locate the master. Client sessions "
"will be closed.", srv->name, srv->port);
srv->master_err_is_logged = true;
@ -1336,7 +1336,7 @@ static void handleError(MXS_ROUTER *instance,
}
else
{
MXS_ERROR("Server %s:%d lost the master status but could not locate the "
MXS_ERROR("Server [%s]:%d lost the master status but could not locate the "
"corresponding backend ref.", srv->name, srv->port);
}
}