Skip to content

Commit

Permalink
Fix --vips-info CLI flag with GLib >= 2.80
Browse files Browse the repository at this point in the history
Use `g_log_writer_default_set_debug_domains()` since resetting
`G_MESSAGES_DEBUG` at runtime has no effect for GLib >= 2.80.

Also, remove any checks for the old `G_MESSAGES_DEBUG` env variable
and overwrite it directly instead. This means the `--vips-info` CLI
flag and the `VIPS_INFO=1` env variable now take precedence over
`G_MESSAGES_DEBUG`.

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3710.
  • Loading branch information
kleisauke committed Nov 12, 2024
1 parent a26dce4 commit 83b2fc3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- fix PFM byte order on big-endian machines [agoode]
- morph: fix erode Highway path [kleisauke]
- morph: fix C-paths with masks containing zero [kleisauke]
- fix `--vips-info` CLI flag with GLib >= 2.80 [kleisauke]

10/10/24 8.16.0

Expand Down
24 changes: 9 additions & 15 deletions libvips/iofuncs/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,24 +363,18 @@ set_stacksize(guint64 size)
#endif /*HAVE_PTHREAD_DEFAULT_NP*/
}

/**
* Equivalent to setting the `G_MESSAGES_DEBUG=VIPS` environment variable.
*/
static void
vips_verbose(void)
{
const char *old;

old = g_getenv("G_MESSAGES_DEBUG");

if (!old)
g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, TRUE);
else if (!g_str_equal(old, "all") &&
!g_strrstr(old, G_LOG_DOMAIN)) {
char *new;

new = g_strconcat(old, " ", G_LOG_DOMAIN, NULL);
g_setenv("G_MESSAGES_DEBUG", new, TRUE);

g_free(new);
}
#if GLIB_CHECK_VERSION(2, 80, 0)
const char *domains[] = { G_LOG_DOMAIN, NULL };
g_log_writer_default_set_debug_domains(domains);
#else
g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, TRUE);
#endif
}

static int
Expand Down

0 comments on commit 83b2fc3

Please sign in to comment.