Improve support for GLib structured logging
Per a post to the list a while ago, I've been investigating moving Geary over to use GLib structured logging, so I can capture rich log files to make it easier to debug bug reports. It's mostly working, but support for this could be improved in Vala, however.
Currently, it's not possible to determine the current source file, line number and function name from within Vala source, meaning it's not possible to log those things. The existing [Diagnostics]
attribute (which is applied to calls such as GLib.debug()
) is a hack for this, but this actually alters the logged message to prefix it with source file name and line number, and duplicating the information because it is already provided by those GLib macros when structured logging is enabled.
One possible improved approach would be to alter the [Diagnostics]
attribute to define some well known macro-like constants for source file name, line number, and function name of the previous stack frame, perhaps called __FILE__
, __LINE__
and __FUNC__
, stop it from appending these to log messages, then remove that annotation from the GLib debugging macros. This would allow applications to use these in custom structured logging infrastructure and get rid of the source file/line number redundancy.