Ethereal-dev: [Ethereal-dev] patch: console log level preference

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Richard van der Hoff <richardv@xxxxxxxxxxxxx>
Date: Tue, 11 Oct 2005 13:22:40 +0100
Hi,

Attached is a patch which makes the console log level (warning/message/debug etc) a configurable preference. There's no gui for setting it, but since it's pretty much only going to be useful for developers, I'm sure you'll cope...

Richard

--
Richard van der Hoff <richardv@xxxxxxxxxxxxx>
Systems Analyst
Tel: +44 (0) 845 666 7778
http://www.mxtelecom.com
Index: epan/prefs.c
===================================================================
RCS file: /cvs/ethereal/epan/prefs.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 prefs.c
--- epan/prefs.c	29 Sep 2005 13:18:53 -0000	1.1.1.3
+++ epan/prefs.c	11 Oct 2005 12:22:06 -0000
@@ -1034,6 +1034,8 @@
   prefs.gui_layout_content_1       = layout_pane_content_plist;
   prefs.gui_layout_content_2       = layout_pane_content_pdetails;
   prefs.gui_layout_content_3       = layout_pane_content_pbytes;
+  prefs.console_log_level          =
+      G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR;
 
 /* set the default values for the capture dialog box */
   prefs.capture_device           = NULL;
@@ -1388,6 +1390,7 @@
 #define PRS_GUI_LAYOUT_CONTENT_1         "gui.layout_content_1"
 #define PRS_GUI_LAYOUT_CONTENT_2         "gui.layout_content_2"
 #define PRS_GUI_LAYOUT_CONTENT_3         "gui.layout_content_3"
+#define PRS_CONSOLE_LOG_LEVEL		 "console.log.level"
 
 /*
  * This applies to more than just captures, so it's not "capture.name_resolve";
@@ -1740,7 +1743,9 @@
   } else if (strcmp(pref_name, PRS_GUI_LAYOUT_CONTENT_3) == 0) {
     prefs.gui_layout_content_3 =
 	find_index_from_string_array(value, gui_layout_content_text, 0);
-
+  } else if (strcmp(pref_name, PRS_CONSOLE_LOG_LEVEL) == 0) {
+    prefs.console_log_level = strtoul(value, NULL, 10);
+        
 /* handle the capture options */
   } else if (strcmp(pref_name, PRS_CAP_DEVICE) == 0) {
     if (prefs.capture_device != NULL)
@@ -2364,6 +2369,18 @@
   fprintf(pf, PRS_GUI_LAYOUT_CONTENT_3 ": %s\n",
 	          gui_layout_content_text[prefs.gui_layout_content_3]);
 
+  fprintf(pf, "\n######## User Interface: Console logging level ########\n");
+  fprintf(pf, "# A bitmask of glib log levels:\n"
+          "# G_LOG_LEVEL_ERROR    = 4\n"
+          "# G_LOG_LEVEL_CRITICAL = 8\n"
+          "# G_LOG_LEVEL_WARNING  = 16\n"
+          "# G_LOG_LEVEL_MESSAGE  = 32\n"
+          "# G_LOG_LEVEL_INFO     = 64\n"
+          "# G_LOG_LEVEL_DEBUG    = 128\n");
+
+  fprintf(pf, PRS_CONSOLE_LOG_LEVEL ": %u\n",
+          prefs.console_log_level);
+
   fprintf (pf, "\n######## User Interface: Columns ########\n");
   
   clp = prefs.col_list;
@@ -2554,6 +2571,7 @@
   dest->gui_geometry_save_maximized = src->gui_geometry_save_maximized;
   dest->gui_webbrowser = g_strdup(src->gui_webbrowser);
   dest->gui_window_title = g_strdup(src->gui_window_title);
+  dest->console_log_level = src->console_log_level;
 /*  values for the capture dialog box */
   dest->capture_device = g_strdup(src->capture_device);
   dest->capture_devices_descr = g_strdup(src->capture_devices_descr);
Index: epan/prefs.h
===================================================================
RCS file: /cvs/ethereal/epan/prefs.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 prefs.h
--- epan/prefs.h	15 Aug 2005 14:45:16 -0000	1.1.1.2
+++ epan/prefs.h	11 Oct 2005 12:22:06 -0000
@@ -139,6 +139,7 @@
   layout_pane_content_e gui_layout_content_1;
   layout_pane_content_e gui_layout_content_2;
   layout_pane_content_e gui_layout_content_3;
+  gint     console_log_level;
   guint32  name_resolve;
   gint     name_resolve_concurrency;
   gchar   *capture_device;
Index: gtk/main.c
===================================================================
RCS file: /cvs/ethereal/gtk/main.c,v
retrieving revision 1.1.1.11
diff -u -r1.1.1.11 main.c
--- gtk/main.c	7 Oct 2005 12:37:29 -0000	1.1.1.11
+++ gtk/main.c	11 Oct 2005 12:22:06 -0000
@@ -2736,9 +2736,7 @@
   const char *level;
 
 
-  /* change this, if you want to see more verbose log output */
-  /* XXX - make this a pref value */
-  if( (log_level & G_LOG_LEVEL_MASK) > G_LOG_LEVEL_WARNING) {
+  if( !(log_level & G_LOG_LEVEL_MASK & prefs.console_log_level)) {
     return;
   }