diff --git a/authservice/mqhtpass/src/log.c b/authservice/mqhtpass/src/log.c index 773cea6..84a8205 100644 --- a/authservice/mqhtpass/src/log.c +++ b/authservice/mqhtpass/src/log.c @@ -25,6 +25,7 @@ limitations under the License. FILE *fp = NULL; int pid; +char hostname[255]; bool debug = false; /** @@ -49,6 +50,8 @@ int log_init_internal(char *filename, const char *mode) { int result = 0; pid = getpid(); + hostname[254] = '\0'; + gethostname(hostname, 254); if (!fp) { 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_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, ", \"message\":\""); diff --git a/authservice/mqhtpass/src/mqhtpass.c b/authservice/mqhtpass/src/mqhtpass.c index 0076661..854d1f9 100644 --- a/authservice/mqhtpass/src/mqhtpass.c +++ b/authservice/mqhtpass/src/mqhtpass.c @@ -271,11 +271,14 @@ static void MQENTRY mqhtpass_terminate( PMQLONG pCompCode, PMQLONG pReason) { - log_infof("Terminating %s", NAME); if (Options == MQZTO_PRIMARY) { + log_infof("Terminating %s", NAME); log_close(); } + else { + log_debugf("Terminating secondary"); + } *pCompCode = MQCC_OK; *pReason = MQRC_NONE; }