[maemo-commits] [maemo-commits] r9189 - projects/haf/trunk/glib/glib
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Jan 19 14:13:37 EET 2007
- Previous message: [maemo-commits] r9188 - projects/haf/branches/gtk+/maemo-gtk-2-10/gdk-pixbuf
- Next message: [maemo-commits] r9190 - in projects/haf/branches/gtk+/maemo-gtk-2-10: . docs/reference docs/reference/gdk gdk gdk/directfb gdk/quartz gdk/win32 gdk/x11
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: tpalli Date: 2007-01-19 14:13:36 +0200 (Fri, 19 Jan 2007) New Revision: 9189 Modified: projects/haf/trunk/glib/glib/gmessages.c Log: use G_LOG_OUTPUT_LEVEL from environment to handle logging output Modified: projects/haf/trunk/glib/glib/gmessages.c =================================================================== --- projects/haf/trunk/glib/glib/gmessages.c 2007-01-19 11:35:02 UTC (rev 9188) +++ projects/haf/trunk/glib/glib/gmessages.c 2007-01-19 12:13:36 UTC (rev 9189) @@ -867,6 +867,18 @@ #define DEFAULT_DOMAIN "default" #define DEFAULT_MESSAGE "(NULL) message" +static unsigned int G_LOG_OUTPUT_LEVEL; + +enum + { + G_LOG_OUTPUT_LEVEL_MIN = 0, + G_LOG_OUTPUT_LEVEL_CRITICAL, + G_LOG_OUTPUT_LEVEL_WARNING, + G_LOG_OUTPUT_LEVEL_MAX + }; + +#define G_LOG_OUTPUT_LEVEL_DEF G_LOG_OUTPUT_LEVEL_MAX + void g_log_default_handler ( const gchar* log_domain, GLogLevelFlags log_level, @@ -884,11 +896,28 @@ const gchar* prefix; int priority; + gchar *output_level; + int level; + /* Check first that logging facility is initialized */ if ( !initialized ) { openlog(NULL, LOG_PERROR|LOG_PID, LOG_USER); initialized = !initialized; + + G_LOG_OUTPUT_LEVEL = G_LOG_OUTPUT_LEVEL_DEF; + + output_level = getenv("G_LOG_OUTPUT_LEVEL"); + if (output_level) + { + level = atoi(output_level); + + if (level >= G_LOG_OUTPUT_LEVEL_MIN && + level <= G_LOG_OUTPUT_LEVEL_MAX) + { + G_LOG_OUTPUT_LEVEL = level; + } + } } /* Validate log domain */ @@ -899,6 +928,31 @@ if ( IS_EMPTY_STRING(message) ) message = DEFAULT_MESSAGE; + + /* no logging on minimal output level */ + if (G_LOG_OUTPUT_LEVEL == G_LOG_OUTPUT_LEVEL_MIN) + { + return; + } + + /* if warning|message and level critical, return */ + if ((log_level & G_LOG_LEVEL_MASK) >= G_LOG_LEVEL_WARNING) + { + if (G_LOG_OUTPUT_LEVEL == (G_LOG_OUTPUT_LEVEL_CRITICAL)) + { + return; + } + } + + /* if message and level warning, return */ + if ((log_level & G_LOG_LEVEL_MASK) >= G_LOG_LEVEL_MESSAGE) + { + if (G_LOG_OUTPUT_LEVEL <= (G_LOG_OUTPUT_LEVEL_WARNING)) + { + return; + } + } + /* Process the message prefix and priority */ switch (log_level & G_LOG_LEVEL_MASK) {
- Previous message: [maemo-commits] r9188 - projects/haf/branches/gtk+/maemo-gtk-2-10/gdk-pixbuf
- Next message: [maemo-commits] r9190 - in projects/haf/branches/gtk+/maemo-gtk-2-10: . docs/reference docs/reference/gdk gdk gdk/directfb gdk/quartz gdk/win32 gdk/x11
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]