int debug;
const char *console_fnkeys[12];
char loglevel[128];
+ int log_uuid;
int quiet;
int batch_mode;
char prompt_color[12];
" -i, --interrupt Allow Control-c to interrupt\n"
" -x, --execute=command Execute Command and Exit\n"
" -l, --loglevel=command Log Level\n"
+ " -U, --log-uuid Include UUID in log output\n"
" -q, --quiet Disable logging\n"
" -r, --retry Retry connection on failure\n"
" -R, --reconnect Reconnect if disconnected\n"
if (aok) {
if (feature_level) clear_line();
if(!(global_profile->batch_mode)) {
- printf("%s%s", colors[level], handle->last_event->body);
+ printf("%s", colors[level]);
+ }
+ if (global_profile->log_uuid && !esl_strlen_zero(userdata)) {
+ printf("%s ", userdata);
+ }
+ printf("%s", handle->last_event->body);
+ if(!(global_profile->batch_mode)) {
if (!feature_level) printf("%s", ESL_SEQ_DEFAULT_COLOR);
- } else {
- printf("%s", handle->last_event->body);
}
if (feature_level) redisplay();
}
if(!(global_profile->batch_mode)) {
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);
if(!(global_profile->batch_mode)) {
SetConsoleTextAttribute(hStdout, wOldColorAttrs);
}
} 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(!strcasecmp(var, "prompt-color")) {
{"debug", 1, 0, 'd'},
{"execute", 1, 0, 'x'},
{"loglevel", 1, 0, 'l'},
+ {"log-uuid", 0, 0, 'U'},
{"quiet", 0, 0, 'q'},
{"batchmode", 0, 0, 'b'},
{"retry", 0, 0, 'r'},
int argv_exec = 0;
char argv_command[1024] = "";
char argv_loglevel[128] = "";
+ int argv_log_uuid = 0;
int argv_quiet = 0;
int argv_batch = 0;
int loops = 2, reconnect = 0, timeout = 0;
esl_global_set_default_logger(6); /* default debug level to 6 (info) */
for(;;) {
int option_index = 0;
- opt = getopt_long(argc, argv, "H:U:P:S:u:p:d:x:l:t:qrRhib?n", options, &option_index);
+ opt = getopt_long(argc, argv, "H:P:S:u:p:d:x:l:Ut:qrRhib?n", options, &option_index);
if (opt == -1) break;
switch (opt) {
case 'H':
case 'l':
esl_set_string(argv_loglevel, optarg);
break;
+ case 'U':
+ argv_log_uuid = 1;
+ break;
case 'q':
argv_quiet = 1;
break;
esl_set_string(profile->loglevel, argv_loglevel);
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);
esl_set_string(prompt_color, profile->prompt_color);
esl_set_string(input_text_color, profile->input_text_color);
static switch_hash_t *log_hash = NULL;
static uint32_t all_level = 0;
static int32_t hard_log_level = SWITCH_LOG_DEBUG;
+static switch_bool_t log_uuid = SWITCH_FALSE;
//static int32_t failed_write = 0;
static void del_mapping(char *var)
{
#endif
} else if (!strcasecmp(var, "loglevel") && !zstr(val)) {
hard_log_level = switch_log_str2level(val);
+ } else if (!strcasecmp(var, "uuid") && switch_true(val)) {
+ log_uuid = SWITCH_TRUE;
}
}
}
DWORD len = (DWORD) strlen(node->data);
DWORD outbytes = 0;
SetConsoleTextAttribute(hStdout, COLORS[node->level]);
+ if (log_uuid && !zstr(node->userdata)) {
+ WriteFile(hStdout, node->userdata, strlen(node->userdata), &outbytes, NULL);
+ WriteFile(hStdout, " ", strlen(" "), &outbytes, NULL);
+ }
WriteFile(hStdout, node->data, len, &outbytes, NULL);
SetConsoleTextAttribute(hStdout, wOldColorAttrs);
#else
- fprintf(handle, "%s%s%s", COLORS[node->level], node->data, SWITCH_SEQ_DEFAULT_COLOR);
+ if (log_uuid && !zstr(node->userdata)) {
+ fprintf(handle, "%s%s %s%s", COLORS[node->level], node->userdata, node->data, SWITCH_SEQ_DEFAULT_COLOR);
+ } else {
+ fprintf(handle, "%s%s%s", COLORS[node->level], node->data, SWITCH_SEQ_DEFAULT_COLOR);
+ }
#endif
+ } else if (log_uuid && !zstr(node->userdata)) {
+ fprintf(handle, "%s %s", node->userdata, node->data);
} else {
fprintf(handle, "%s", node->data);
}