Add hostname to log
This commit is contained in:
committed by
Arthur J Barr
parent
ac3dcdd0d0
commit
12a2dee175
@@ -25,6 +25,7 @@ limitations under the License.
|
|||||||
|
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
int pid;
|
int pid;
|
||||||
|
char hostname[255];
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,6 +50,8 @@ int log_init_internal(char *filename, const char *mode)
|
|||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
|
hostname[254] = '\0';
|
||||||
|
gethostname(hostname, 254);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
fp = fopen(filename, "a");
|
fp = fopen(filename, "a");
|
||||||
@@ -124,6 +127,7 @@ void log_printf(const char *source_file, int source_line, const char *level, con
|
|||||||
cur += snprintf(cur, end-cur, ", \"ibm_datetime\":\"%s.%03ldZ\"", date_buf, now.tv_usec / 1000);
|
cur += snprintf(cur, end-cur, ", \"ibm_datetime\":\"%s.%03ldZ\"", date_buf, now.tv_usec / 1000);
|
||||||
}
|
}
|
||||||
cur += snprintf(cur, end-cur, ", \"ibm_processId\":\"%d\"", pid);
|
cur += snprintf(cur, end-cur, ", \"ibm_processId\":\"%d\"", pid);
|
||||||
|
cur += snprintf(cur, end-cur, ", \"host\":\"%s\"", hostname);
|
||||||
cur += snprintf(cur, end-cur, ", \"module\":\"%s:%d\"", source_file, source_line);
|
cur += snprintf(cur, end-cur, ", \"module\":\"%s:%d\"", source_file, source_line);
|
||||||
cur += snprintf(cur, end-cur, ", \"message\":\"");
|
cur += snprintf(cur, end-cur, ", \"message\":\"");
|
||||||
|
|
||||||
|
|||||||
@@ -271,11 +271,14 @@ static void MQENTRY mqhtpass_terminate(
|
|||||||
PMQLONG pCompCode,
|
PMQLONG pCompCode,
|
||||||
PMQLONG pReason)
|
PMQLONG pReason)
|
||||||
{
|
{
|
||||||
log_infof("Terminating %s", NAME);
|
|
||||||
if (Options == MQZTO_PRIMARY)
|
if (Options == MQZTO_PRIMARY)
|
||||||
{
|
{
|
||||||
|
log_infof("Terminating %s", NAME);
|
||||||
log_close();
|
log_close();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
log_debugf("Terminating secondary");
|
||||||
|
}
|
||||||
*pCompCode = MQCC_OK;
|
*pCompCode = MQCC_OK;
|
||||||
*pReason = MQRC_NONE;
|
*pReason = MQRC_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user