Added an option to filter logs by lebel.
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4356 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
@@ -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("");
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user