wok-next view glib/stuff/patches/glib-2.54.3-skip_warnings-1.patch @ rev 20700

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