GLib 2.63.1 will be released in the next few weeks, and will contain a fun new API to slightly simplify emitting a warning once, and then shutting up to avoid emitting loads of log spam.
g_warning_once(), and works just like
Thanks to Jonas Ådahl for putting it together!
From a discussion on #gtk+ this morning: if you’re using recent versions of GLib with structured logging support, and you want to work out which bit of your code is causing a certain message to be printed to the terminal, run your application in gdb and add a breakpoint on g_log_writer_standard_streams.
(This assumes you’re using the default log writer function; if not, you need to add a breakpoint on something in your writer function.)