Difference between revisions of "Logging"

From GnuCash
Jump to: navigation, search
(Add breakout for defined log domains in GnuCash)
(Add breakout for defined log domains in GnuCashand log levels)
Line 7: Line 7:
 
= Logging in GnuCash =
 
= Logging in GnuCash =
  
GnuCash leverages glib logging, with some historical and convenience macros.  Since 2007 GnuCash has used an ad-hoc layer on top of glib's "gmessage.h" logging inspired by log4j.  In short, '''messages''' are logged in a given [[GnuCash Log Domains |'''log-domains''']] and at a specific '''level'''.  The log-domain is a "."-separated path, and a table of log levels is configured.  Between the two, a tree of log-level is established.  Log messages are checked against the tree before being emitted.
+
GnuCash leverages glib logging, with some historical and convenience macros.  Since 2007 GnuCash has used an ad-hoc layer on top of glib's "gmessage.h" logging inspired by log4j.  In short, '''messages''' are logged in a given [[GnuCash Log Domains |'''log-domains''']] and at a specific [[GnuCash Log-levels |'''log-level''']].  The log-domain is a "."-separated path, and a table of log levels is configured.  Between the two, a tree of log-level is established.  Log messages are checked against the tree before being emitted.
  
  

Revision as of 05:53, 4 September 2018

For users: See Tracefile and Stack Trace on how to look up the logging information after some problem occurred.

For developers: See the Logging API documentation, as well. So each module defines its own log_domain. Best way to figure out what to use is to look at the top of the .c file and look for the LOG_MODULE. E.g. print-session.c defines G_LOG_DOMAIN "gnc.printing".

The rest of this page is targeted towards developers.

Logging in GnuCash

GnuCash leverages glib logging, with some historical and convenience macros. Since 2007 GnuCash has used an ad-hoc layer on top of glib's "gmessage.h" logging inspired by log4j. In short, messages are logged in a given log-domains and at a specific log-level. The log-domain is a "."-separated path, and a table of log levels is configured. Between the two, a tree of log-level is established. Log messages are checked against the tree before being emitted.


The special file ~/.gnucash/log.conf is checked for at gnucash start up; if present, its contents will configure the logging subsystem. The primary purpose of the configuration file it to setup a specific set of log-levels, though it's also useful for changing the default logging location from /tmp/gnucash.trace to stdout, stderr or another file.

The specific set of log paths that exist are going to be a function of the code at any given point, but some basic patterns will stabilize. As of Feb 13 2007, User:Jsled is using the following to generally raise the log level of the app, but also to get debugging detail about file-backend and U I code changes related to scheduled transactions:

   [levels]
   gnc=message
   
   gnc.bin=info
   gnc.gui=info
   gnc.backend.file=info
   
   gnc.engine.sx=debug
   gnc.app-util.sx=debug
   gnc.backend.file.sx=debug
   gnc.gui.sx=debug
   gnc.gui.frequency=debug
   
   GLib=error
   
   [output]
   to=stderr


Note that these settings are probably not suitable for your purpose, but serve as an example of what's possible.