After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 771218 - Use structured logging
Use structured logging
Status: RESOLVED FIXED
Product: polari
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Polari maintainers
Polari maintainers
Depends on:
Blocks:
 
 
Reported: 2016-09-10 23:41 UTC by Florian Müllner
Modified: 2016-10-09 14:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
main: Make Utils.debug() globally available (6.74 KB, patch)
2016-09-10 23:41 UTC, Florian Müllner
none Details | Review
main: Use structured log for logging (2.85 KB, patch)
2016-09-10 23:41 UTC, Florian Müllner
none Details | Review
lib: Turn on structured logging (1005 bytes, patch)
2016-09-10 23:41 UTC, Florian Müllner
committed Details | Review
main: Turn on all messages when logging to journal (1.29 KB, patch)
2016-09-10 23:41 UTC, Florian Müllner
committed Details | Review
main: Use structured log for logging (3.39 KB, patch)
2016-09-10 23:46 UTC, Florian Müllner
none Details | Review
main: Make Utils.debug() globally available (6.19 KB, patch)
2016-09-15 12:12 UTC, Florian Müllner
committed Details | Review
main: Use structured log for logging (3.37 KB, patch)
2016-09-15 12:13 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2016-09-10 23:41:09 UTC
See patches. Note that these patches need up-to-date checkouts of both glib and gobject-introspection.
Comment 1 Florian Müllner 2016-09-10 23:41:14 UTC
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.
Comment 2 Florian Müllner 2016-09-10 23:41:20 UTC
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.
Comment 3 Florian Müllner 2016-09-10 23:41:27 UTC
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) ...
Comment 4 Florian Müllner 2016-09-10 23:41:33 UTC
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.
Comment 5 Florian Müllner 2016-09-10 23:46:13 UTC
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 :-)
Comment 6 Florian Müllner 2016-09-15 12:12:36 UTC
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 ...
Comment 7 Florian Müllner 2016-09-15 12:13:04 UTC
Created attachment 335625 [details] [review]
main: Use structured log for logging

Use debug(), info(), warning() etc. instead of logDebug(), logInfo() and logWarning().
Comment 8 Bastian Ilsø 2016-10-09 11:54:49 UTC
Review of attachment 335624 [details] [review]:

looks good to me
Comment 9 Bastian Ilsø 2016-10-09 12:00:35 UTC
Review of attachment 335625 [details] [review]:

looks good to me.
Comment 10 Bastian Ilsø 2016-10-09 14:56:06 UTC
Review of attachment 335284 [details] [review]:

looks good to me
Comment 11 Bastian Ilsø 2016-10-09 14:56:24 UTC
Review of attachment 335285 [details] [review]:

looks good to me
Comment 12 Florian Müllner 2016-10-09 14:58:46 UTC
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