I would like to redirect messages from g_warning() and similar functions from gtkbuilder.c such as the famous:
(main.exe:39280): Gtk-WARNING **: 01:34:48.787: Could not find signal
ha ndler ‘on_window_realize’. Did you compile with -rdynamic?
using g_log_set_handler(). It expects the domain name as the first parameter, which is what I can’t seem to find. If G_LOG_DOMAIN is not defined in the source then it defaults to NULL in which case I won’t be able to use g_log_set_handler() to redirect it.
What is the log domain name for it or alternatively - how can I redirect those messages after all (I am redirecting them to a GtkTextBuffer)?
All warnings coming from GTK have a Gtk log domain.
Libraries typically define their own log domain; ideally, this would be documented in the API reference, but if it isn’t, you can still check the source code for G_LOG_DOMAIN definitions.
How do I do that? I don’t use github. It appears to me that I’ll have to devote a lot of time in investigations and I may not find a solution to the problem, which is why I am relying on someone who already knows this.
The documentation about GtkBuilder does not mention this, probably, because it is self-explanatory in some way.
I already have set a handler from “Gtk” domain and this does not filter those messages.
Nope, I am re-writing application, which leaves it with trailing signal handlers specified by Glade.
I want to use my own Gtk-based debug terminal to filter out certain messages.
Ah, of course: GTK is using structured logging, which means the g_log_set_handler() won’t work:
This has no effect if structured logging is enabled;
see [Using Structured Logging][using-structured-logging].
You will need to use g_log_set_writer_func() instead, with your GLogWriterFunc callback. The log domain is inside the GLIB_DOMAIN field in the GLogField data structure passed to the callback.
Ah, thanks. I will try that. I did read about “structured logging”, but I wasn’t familiar with this term. I didn’t know what exactly it means and how to get around it. It was a bit confusing to be honest.
By the way, I admire your work
Quite big of a GTK+ application is coming soon. Where do you suggest me announcing it?
Which community will be happiest about showcasing GTK+ applications? The bigger one if possible.
As I said, those are expected messages because of the lacking signal handlers in the sources due to rewriting from scratch, using the same gui description file. I’ll be slowly implementing them. I am not “silencing” the problem. I said that I am simply redirecting the output to a custom terminal. Other than the fact that what you said has nothing to do with me, you are absolutely right.