Difference between revisions of "GnuCash Log Domains"

From GnuCash
Jump to: navigation, search
(Add breakout for defined log domains in GnuCash)
 
m (GnuCash log-domains: link gnc_engine.h and update its content)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
= GnuCash log-domains =
 
= GnuCash log-domains =
The following domains are defined for Gnucash (as at 4th Sept., 2018) by macros in gnc_engine.h.
+
The following domains associated with specific modules in the GnuCash code are defined for Gnucash (as at 2023-04-18) by macros in [{{URL:git}}gnucash/blob/stable/libgnucash/engine/gnc-engine.h#L49-L71 gnc_engine.h].
 
<syntaxhighlight lang="C">
 
<syntaxhighlight lang="C">
 
#define GNC_MOD_ROOT      "gnc"
 
#define GNC_MOD_ROOT      "gnc"
Line 24: Line 24:
 
#define GNC_MOD_IMPORT    "gnc.import"
 
#define GNC_MOD_IMPORT    "gnc.import"
 
#define GNC_MOD_ASSISTANT "gnc.assistant"
 
#define GNC_MOD_ASSISTANT "gnc.assistant"
#define GNC_MOD_TEST      "gnc.tests"
 
 
#define GNC_MOD_BUDGET    "gnc.budget"
 
#define GNC_MOD_BUDGET    "gnc.budget"
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
The '''log-domain''' applied a given section of code is defined by including a line of the form:
 
The '''log-domain''' applied a given section of code is defined by including a line of the form:
<syntaxhighlight lang="C">static QofLogModule log_module = GNC_MOD_IMPORT;</syntaxhighlight>
+
<syntaxhighlight lang="C">static QofLogModule log_module = GNC_MOD_IMPORT;</syntaxhighlight> or <syntaxhighlight lang="C">#define G_LOG_DOMAIN GNC_MOD_IMPORT;</syntaxhighlight> or <syntaxhighlight lang="C">#define G_LOG_DOMAIN "gnc.import";</syntaxhighlight>.
substituting the appropriate macro from the above list in the C code after header files have been included. It should not be placed in any public header files as these may be include by C code in other code areas which are not in the specified domain. They define specific areas of the code where a '''log-level''' can be set to control the level of logging information logged by that area of code. When setting log-domains either in ./gnucash/log.conf or when supplied as command line arguments the string enclosed in quotes above is used to refer to the log-domain, e.g. The command line switch<syntaxhighlight lang="sh">$gnucash --log gnc.import=debug </syntaxhighlight> enables debug level information to be output by code which is defined in the log-domain gnc.import, where gnc refers to gnucash and import refers to areas of code associated with importing data.
+
* The first or second form is preferred as the specific string can then be easily changed at all points in the code by just altering the definition of the macros in gnc_engine.h but you will sometimesfind the third form used to define further subdomains for more detailed debugging ofr example.
 +
* Substitute the appropriate macro from the above list. This line should be placed in the in the C file after header files have been included.  
 +
* This line should '''not''' be placed in any public header files as these may be include by C code in other code areas which are not in the specified domain.  
 +
 
 +
The '''log-domains''' define specific modules or areas of the code where a [[GnuCash Log-levels |'''log-level''']] can be set to control the level of logging information logged by that area of code. When setting a log-level for given log-domain, either in ./gnucash/log.conf or supplied as command line arguments, the string enclosed in quotes above is used to refer to the log-domain.
 +
 
 +
E.g. The command line switch<syntaxhighlight lang="sh">$gnucash --log gnc.import=debug </syntaxhighlight> when GnuCash is started enables debug level information to be output by code which is defined in the log-domain gnc.import, where gnc refers to gnucash generally and import refers to code modules associated with importing data.
 +
 
 +
Return to [[Logging]].

Latest revision as of 23:41, 18 April 2023

GnuCash log-domains

The following domains associated with specific modules in the GnuCash code are defined for Gnucash (as at 2023-04-18) by macros in gnc_engine.h.

#define GNC_MOD_ROOT      "gnc"
#define GNC_MOD_ENGINE    "gnc.engine"
#define GNC_MOD_ACCOUNT   "gnc.account"
#define GNC_MOD_SX        "gnc.engine.sx"
#define GNC_MOD_QUERY     "gnc.query"
#define GNC_MOD_SCRUB     "gnc.scrub"
#define GNC_MOD_LOT       "gnc.lots"
#define GNC_MOD_COMMODITY "gnc.commodity"
#define GNC_MOD_BACKEND   "gnc.backend"
#define GNC_MOD_PRICE     "gnc.pricedb"
#define GNC_MOD_BUSINESS  "gnc.business"
#define GNC_MOD_IO        "gnc.io"
#define GNC_MOD_BOOK      "gnc.book-period"
#define GNC_MOD_GUI       "gnc.gui"
#define GNC_MOD_GUI_SX    "gnc.gui.sx"
#define GNC_MOD_GUILE     "gnc.guile"
#define GNC_MOD_LEDGER    "gnc.ledger"
#define GNC_MOD_REGISTER  "gnc.register"
#define GNC_MOD_HTML      "gnc.html"
#define GNC_MOD_PREFS     "gnc.pref"
#define GNC_MOD_IMPORT    "gnc.import"
#define GNC_MOD_ASSISTANT "gnc.assistant"
#define GNC_MOD_BUDGET    "gnc.budget"

The log-domain applied a given section of code is defined by including a line of the form:

static QofLogModule log_module = GNC_MOD_IMPORT;
or
#define G_LOG_DOMAIN GNC_MOD_IMPORT;
or
#define G_LOG_DOMAIN "gnc.import";
.
  • The first or second form is preferred as the specific string can then be easily changed at all points in the code by just altering the definition of the macros in gnc_engine.h but you will sometimesfind the third form used to define further subdomains for more detailed debugging ofr example.
  • Substitute the appropriate macro from the above list. This line should be placed in the in the C file after header files have been included.
  • This line should not be placed in any public header files as these may be include by C code in other code areas which are not in the specified domain.

The log-domains define specific modules or areas of the code where a log-level can be set to control the level of logging information logged by that area of code. When setting a log-level for given log-domain, either in ./gnucash/log.conf or supplied as command line arguments, the string enclosed in quotes above is used to refer to the log-domain.

E.g. The command line switch
$gnucash --log gnc.import=debug
when GnuCash is started enables debug level information to be output by code which is defined in the log-domain gnc.import, where gnc refers to gnucash generally and import refers to code modules associated with importing data.

Return to Logging.