wok-next annotate glib/stuff/patches/glib-2.54.3-skip_warnings-1.patch @ rev 20921

flake8 -> python-flake8
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Aug 22 11:18:36 2018 +0300 (2018-08-22)
parents
children
rev   line source
al@20700 1 Submitted By: Bruce dubbs <bdubbs@linuxfromscratch.org>
al@20700 2 Date: 2017-10-15
al@20700 3 Initial Package Version: 2.54.0
al@20700 4 Upstream Status: Not submitted
al@20700 5 Origin: Self
al@20700 6 Description: Adds a capabiility to skip printing warning messages using
al@20700 7 an environment variable: GLIB_LOG_LEVEL. The value
al@20700 8 of the variable is a digit that correponds to:
al@20700 9 1 Alert
al@20700 10 2 Critical
al@20700 11 3 Error
al@20700 12 4 Warning
al@20700 13 5 Notice
al@20700 14
al@20700 15 For instance GLIB_LOG_LEVEL=4 will skip output of Waring and
al@20700 16 Notice messages (and Info/Debug messages if they are turned on).
al@20700 17
al@20700 18 --- glib-2.54.0/glib/gmessages.c 2017-08-19 08:39:20.000000000 -0500
al@20700 19 +++ glib-2.54.0-new/glib/gmessages.c 2017-10-15 14:45:52.004885278 -0500
al@20700 20 @@ -523,6 +523,35 @@
al@20700 21
al@20700 22 /* --- functions --- */
al@20700 23
al@20700 24 +/* skip_message
al@20700 25 + *
al@20700 26 + * This internal function queries an optional environment variable,
al@20700 27 + * GLIB_LOG_LEVEL and converts it to a value consistent
al@20700 28 + * with the type GLogLevelFlags. If the value is equal to
al@20700 29 + * or greater than the integer equivalent of the log_level.
al@20700 30 + * then the function returns a boolean that indicates that
al@20700 31 + * loging the output should be skipped.
al@20700 32 + */
al@20700 33 +
al@20700 34 +static gboolean skip_message( GLogLevelFlags log_level);
al@20700 35 +
al@20700 36 +static gboolean skip_message( GLogLevelFlags log_level)
al@20700 37 +{
al@20700 38 + char* user_log_level;
al@20700 39 + int user_log_int;
al@20700 40 + gboolean skip = FALSE;
al@20700 41 +
al@20700 42 + user_log_level = getenv( "GLIB_LOG_LEVEL" );
al@20700 43 +
al@20700 44 + user_log_int = ( user_log_level != NULL ) ? atoi( user_log_level ) : 0;
al@20700 45 + user_log_int = ( user_log_int != 0 ) ? 1 << user_log_int : 0;
al@20700 46 +
al@20700 47 + if ( user_log_int >= log_level ) skip = TRUE;
al@20700 48 +
al@20700 49 + return skip;
al@20700 50 +}
al@20700 51 +
al@20700 52 +
al@20700 53 static void _g_log_abort (gboolean breakpoint);
al@20700 54
al@20700 55 static void
al@20700 56 @@ -2496,6 +2525,9 @@
al@20700 57 g_return_val_if_fail (fields != NULL, G_LOG_WRITER_UNHANDLED);
al@20700 58 g_return_val_if_fail (n_fields > 0, G_LOG_WRITER_UNHANDLED);
al@20700 59
al@20700 60 + /* If the user does not want this message level, just return */
al@20700 61 + if ( skip_message( log_level) ) return G_LOG_WRITER_HANDLED;
al@20700 62 +
al@20700 63 stream = log_level_to_file (log_level);
al@20700 64 if (!stream || fileno (stream) < 0)
al@20700 65 return G_LOG_WRITER_UNHANDLED;
al@20700 66 @@ -2640,6 +2672,9 @@
al@20700 67 FILE *stream;
al@20700 68 gsize i;
al@20700 69
al@20700 70 + /* If the user does not want this message level, just return */
al@20700 71 + if ( skip_message( log_level) ) return G_LOG_WRITER_HANDLED;
al@20700 72 +
al@20700 73 /* we cannot call _any_ GLib functions in this fallback handler,
al@20700 74 * which is why we skip UTF-8 conversion, etc.
al@20700 75 * since we either recursed or ran out of memory, we're in a pretty