diff --git a/common/utils/itti_analyzer/itti_analyzer.c b/common/utils/itti_analyzer/itti_analyzer.c index 94f5c1c191e314c3e90790f5e5d2040cce6a7c7b..d82dd06399d9b7fbc8376fe7b7c3f3e90f0becda 100644 --- a/common/utils/itti_analyzer/itti_analyzer.c +++ b/common/utils/itti_analyzer/itti_analyzer.c @@ -26,7 +26,10 @@ console_log_handler(const char *log_domain, GLogLevelFlags log_level, struct tm *today; const char *level; - switch(log_level & G_LOG_LEVEL_MASK) { + if (ui_main_data.log_flags & log_level) + { + switch (log_level & G_LOG_LEVEL_MASK) + { case G_LOG_LEVEL_ERROR: level = "Err "; break; @@ -50,16 +53,15 @@ console_log_handler(const char *log_domain, GLogLevelFlags log_level, level = NULL; g_assert_not_reached(); break; - } + } - /* create a "timestamp" */ - time(&curr); - today = localtime(&curr); + /* create a "timestamp" */ + time(&curr); + today = localtime(&curr); - fprintf(stderr, "%02u:%02u:%02u %8s %s %s\n", - today->tm_hour, today->tm_min, today->tm_sec, - log_domain != NULL ? log_domain : "", - level, message); + fprintf(stderr, "%02u:%02u:%02u %8s %s %s\n", today->tm_hour, today->tm_min, today->tm_sec, + log_domain != NULL ? log_domain : "", level, message); + } } int main(int argc, char *argv[]) diff --git a/common/utils/itti_analyzer/libui/ui_main_screen.c b/common/utils/itti_analyzer/libui/ui_main_screen.c index f622ac4814a6ddd272bcc8a946abd3cfc88de192..7512c4872ddaaf4cf35ccab7be3c59c756067aea 100644 --- a/common/utils/itti_analyzer/libui/ui_main_screen.c +++ b/common/utils/itti_analyzer/libui/ui_main_screen.c @@ -26,9 +26,11 @@ static void ui_help(void) { printf ("Usage: itti_analyser [options]\n\n" "Options:\n" + " -d DISSECT write DISSECT file with message types parse details\n" " -f FILTERS read filters from FILTERS file\n" " -h display this help and exit\n" " -i IP set ip address to IP\n" + " -l LEVEL set log level to LEVEL in the range of 2 to 7\n" " -m MESSAGES read messages from MESSAGES file\n" " -p PORT set port to PORT\n"); } @@ -37,10 +39,18 @@ static void ui_gtk_parse_arg(int argc, char *argv[]) { char c; - while ((c = getopt (argc, argv, "f:hi:m:p:")) != -1) + while ((c = getopt (argc, argv, "d:f:hi:l:m:p:")) != -1) { switch (c) { + case 'd': + ui_main_data.dissect_file_name = malloc (strlen (optarg) + 1); + if (ui_main_data.dissect_file_name != NULL) + { + strcpy (ui_main_data.dissect_file_name, optarg); + } + break; + case 'f': ui_main_data.filters_file_name = malloc (strlen (optarg) + 1); if (ui_main_data.filters_file_name != NULL) @@ -58,6 +68,26 @@ static void ui_gtk_parse_arg(int argc, char *argv[]) ui_main_data.ip_entry_init = optarg; break; + case 'l': + { + GLogLevelFlags log_flag; + + log_flag = 1 << atoi(optarg); + if (log_flag < G_LOG_LEVEL_ERROR) + { + log_flag = G_LOG_LEVEL_ERROR; + } + else + { + if (log_flag > G_LOG_LEVEL_DEBUG) + { + log_flag = G_LOG_LEVEL_DEBUG; + } + } + ui_main_data.log_flags = ((log_flag << 1) - 1) & G_LOG_LEVEL_MASK; + break; + } + case 'm': ui_main_data.messages_file_name = malloc (strlen (optarg) + 1); if (ui_main_data.messages_file_name != NULL) @@ -125,16 +155,21 @@ int ui_gtk_initialize(int argc, char *argv[]) memset (&ui_main_data, 0, sizeof(ui_main_data_t)); - /* Set some default initialization value */ + /* Set some default initialization value for the IP address */ ui_main_data.ip_entry_init = "127.0.0.1"; ui_main_data.port_entry_init = "10007"; + /* Set default log level to all but debug message */ + ui_main_data.log_flags = (G_LOG_LEVEL_MASK & (~G_LOG_LEVEL_DEBUG)); + ui_gtk_parse_arg (argc, argv); /* Create the main window */ ui_main_data.window = gtk_window_new (GTK_WINDOW_TOPLEVEL); ui_init_filters (TRUE, FALSE); + gtk_window_set_default_icon_name (GTK_STOCK_FIND); + gtk_window_set_position (GTK_WINDOW(ui_main_data.window), GTK_WIN_POS_CENTER); gtk_window_set_default_size (GTK_WINDOW(ui_main_data.window), 1024, 800); ui_set_title(""); diff --git a/common/utils/itti_analyzer/libui/ui_main_screen.h b/common/utils/itti_analyzer/libui/ui_main_screen.h index 1a14588edad3cc165c3bef5a847b782134c21340..c9b91f8d9eaffa1825fda8bcfd158bf7eda4182e 100644 --- a/common/utils/itti_analyzer/libui/ui_main_screen.h +++ b/common/utils/itti_analyzer/libui/ui_main_screen.h @@ -16,6 +16,7 @@ typedef struct { /* Buttons */ GtkToolItem *open_replay_file; + GtkToolItem *refresh_replay_file; GtkToolItem *save_replay_file; GtkToolItem *open_filters_file; GtkToolItem *save_filters_file; @@ -35,6 +36,8 @@ typedef struct { /* Nb of messages received */ guint nb_message_received; + GLogLevelFlags log_flags; + char *dissect_file_name; char *filters_file_name; char *messages_file_name;