Do not depend on GLib API introduced after 2.66

To avoid bleeding edge deprecations we use GLIB_VERSION_MIN_REQUIRED and
GLIB_VERSION_MAX_ALLOWED. Since we depend on GLib 2.66, we cannot use
API introduced in 2.67, even when conditionally compiled.
This commit is contained in:
Emmanuele Bassi 2020-11-23 12:02:21 +00:00
parent 3e996f61ae
commit 3a1b2083d6

View File

@ -52,16 +52,17 @@ usage (void)
exit (1); exit (1);
} }
#if !GLIB_CHECK_VERSION(2,67,0) /* A simplified version of g_log_writer_default_would_drop(), to avoid
* bumping up the required version of GLib to 2.68
*/
static gboolean static gboolean
g_log_writer_default_would_drop (GLogLevelFlags level, would_drop (GLogLevelFlags level,
const char *domain) const char *domain)
{ {
return (level & (G_LOG_LEVEL_ERROR | return (level & (G_LOG_LEVEL_ERROR |
G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_CRITICAL |
G_LOG_LEVEL_WARNING)) == 0; G_LOG_LEVEL_WARNING)) == 0;
} }
#endif
static GLogWriterOutput static GLogWriterOutput
log_writer_func (GLogLevelFlags level, log_writer_func (GLogLevelFlags level,
@ -81,7 +82,7 @@ log_writer_func (GLogLevelFlags level,
message = fields[i].value; message = fields[i].value;
} }
if (message != NULL && !g_log_writer_default_would_drop (level, domain)) if (message != NULL && !would_drop (level, domain))
{ {
const char *prefix; const char *prefix;
switch (level & G_LOG_LEVEL_MASK) switch (level & G_LOG_LEVEL_MASK)