diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 91836b7..b541822 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -62,6 +62,7 @@ typedef struct { int debug; const char *console_fnkeys[12]; char loglevel[128]; + int log_uuid; int quiet; } cli_profile_t; @@ -565,6 +566,7 @@ static int usage(char *name){ printf(" -p, --password=password Password\n"); printf(" -x, --execute=command Execute Command and Exit\n"); printf(" -l, --loglevel=command Log Level\n"); + printf(" -U, --log-uuid Include UUID in log output\n"); printf(" -q, --quiet Disable logging\n"); printf(" -r, --retry Retry connection on failure\n"); printf(" -R, --reconnect Reconnect if disconnected\n"); @@ -607,10 +609,19 @@ static void *msg_thread_run(esl_thread_t *me, void *obj) #ifdef WIN32 SetConsoleTextAttribute(hStdout, COLORS[level]); + if (global_profile->log_uuid && !esl_strlen_zero(userdata)) { + WriteFile(hStdout, userdata, strlen(userdata), &outbytes, NULL); + WriteFile(hStdout, " ", strlen(" "), &outbytes, NULL); + } WriteFile(hStdout, handle->last_event->body, len, &outbytes, NULL); SetConsoleTextAttribute(hStdout, wOldColorAttrs); #else - printf("%s%s%s", COLORS[level], handle->last_event->body, ESL_SEQ_DEFAULT_COLOR); + if (global_profile->log_uuid && !esl_strlen_zero(userdata)) { + printf("%s%s %s%s", COLORS[level], userdata, handle->last_event->body, ESL_SEQ_DEFAULT_COLOR); + } + else { + printf("%s%s%s", COLORS[level], handle->last_event->body, ESL_SEQ_DEFAULT_COLOR); + } #endif } known++; @@ -988,6 +999,7 @@ int main(int argc, char *argv[]) {"debug", 1, 0, 'd'}, {"execute", 1, 0, 'x'}, {"loglevel", 1, 0, 'l'}, + {"log-uuid", 0, 0, 'U'}, {"quiet", 0, 0, 'q'}, {"retry", 0, 0, 'r'}, {"reconnect", 0, 0, 'R'}, @@ -1007,6 +1019,7 @@ int main(int argc, char *argv[]) int argv_exec = 0; char argv_command[256] = ""; char argv_loglevel[128] = ""; + int argv_log_uuid = 0; int argv_quiet = 0; int loops = 2, reconnect = 0; @@ -1030,7 +1043,7 @@ int main(int argc, char *argv[]) for(;;) { int option_index = 0; - opt = getopt_long(argc, argv, "H:U:P:S:u:p:d:x:l:qrRh?", options, &option_index); + opt = getopt_long(argc, argv, "H:P:S:u:p:d:x:l:UqrRh?", options, &option_index); if (opt == -1) break; switch (opt) { @@ -1071,6 +1084,9 @@ int main(int argc, char *argv[]) case 'l': esl_set_string(argv_loglevel, optarg); break; + case 'U': + argv_log_uuid = 1; + break; case 'q': argv_quiet = 1; break; @@ -1133,6 +1149,8 @@ int main(int argc, char *argv[]) } } else if(!strcasecmp(var, "loglevel")) { esl_set_string(profiles[pcount-1].loglevel, val); + } else if(!strcasecmp(var, "log-uuid")) { + profiles[pcount-1].log_uuid = esl_true(val); } else if(!strcasecmp(var, "quiet")) { profiles[pcount-1].quiet = esl_true(val); } else if (!strncasecmp(var, "key_F", 5)) { @@ -1185,6 +1203,10 @@ int main(int argc, char *argv[]) profile->quiet = 0; } + if (argv_log_uuid) { + profile->log_uuid = 1; + } + esl_log(ESL_LOG_DEBUG, "Using profile %s [%s]\n", profile->name, profile->host); if (argv_host) {