GNOME Bugzilla – Bug 771218
Use structured logging
Last modified: 2016-10-09 14:59:03 UTC
See patches. Note that these patches need up-to-date checkouts of both glib and gobject-introspection.
Created attachment 335282 [details] [review] main: Make Utils.debug() globally available We should be more generous with logging debug messages, so make it a tad bit more convenient by not requiring a special import.
Created attachment 335283 [details] [review] main: Use structured log for logging GLib gained the ability to log structured data rather than plain strings this cycle, and with the addition of g_log_variant(), we are now able to use it from introspection to add additional useful information to our log messages when connected to the journal. And when logging to the console, we are at least using the standard GLib logging, which means no custom env variables anymore, support for fatal-warnings etc.
Created attachment 335284 [details] [review] lib: Turn on structured logging Let's also turn this on for our C code (and all platform libraries it uses) ...
Created attachment 335285 [details] [review] main: Turn on all messages when logging to journal Unless turned on with the G_MESSAGES_DEBUG env variable, the default log functions drop debug and info messages. While this behavior is reasonable when writing to the console, the journal's log viewer already filters messages by priority by default, so it makes more sense to log everything in that case, as we won't have to ask people to reproduce issues with debugging turned on.
Created attachment 335286 [details] [review] main: Use structured log for logging Heh, instead of telling people on bugzilla what is required for the patches, I can just add a configure check :-)
Created attachment 335624 [details] [review] main: Make Utils.debug() globally available I used the log+level pattern to avoid conflicts ("info" and "message" are commonly used as variable names in the code, though I ended up with log() instead of logMessage() anyway in the follow-up patch), but completely overlooked that logError() was actually taken to log an exception. Meh, just go back to unprefixed log functions - if we ever want to log a message of level INFO where there's a conflict with a local variable, we'll just have to rename the latter ...
Created attachment 335625 [details] [review] main: Use structured log for logging Use debug(), info(), warning() etc. instead of logDebug(), logInfo() and logWarning().
Review of attachment 335624 [details] [review]: looks good to me
Review of attachment 335625 [details] [review]: looks good to me.
Review of attachment 335284 [details] [review]: looks good to me
Review of attachment 335285 [details] [review]: looks good to me
Attachment 335284 [details] pushed as 117e4e2 - lib: Turn on structured logging Attachment 335285 [details] pushed as d75cb82 - main: Turn on all messages when logging to journal Attachment 335624 [details] pushed as 52660ff - main: Make Utils.debug() globally available Attachment 335625 [details] pushed as 8915ac4 - main: Use structured log for logging