Difference between revisions of "GnuCash Log-levels"
Line 26: | Line 26: | ||
GnuCash also defines two similar macros '''ENTER(format, args...)''' and '''LEAVE(format, args...)''' to record the entry to and exit from a C function. '''ENTER''' is placed immediately before any executable code on entry to a function and '''LEAVE''' immediately before any exit point from the function. The '''format''' and '''args''' in all the macros are as defined for a standard '''printf()''' function. | GnuCash also defines two similar macros '''ENTER(format, args...)''' and '''LEAVE(format, args...)''' to record the entry to and exit from a C function. '''ENTER''' is placed immediately before any executable code on entry to a function and '''LEAVE''' immediately before any exit point from the function. The '''format''' and '''args''' in all the macros are as defined for a standard '''printf()''' function. | ||
− | <sup>*</sup> Can be made to exit the program by seting the environment variable <syntaxhighlight lang="sh">G_DEBUG=fatal-warnings gdb ./my-program</syntaxhighlight> or calling the Glib function <syntaxhighlight lang="C">g_log_set_always_fatal ()</syntaxhighlight> | + | <sup>*</sup> Can be made to exit the program by seting the environment variable <syntaxhighlight lang="sh">G_DEBUG=fatal-warnings gdb ./my-program</syntaxhighlight> or calling the Glib function <syntaxhighlight lang="C">g_log_set_always_fatal (); </syntaxhighlight> in your code (not very flexible). |
The form of the PERR macro which calls the GLib logging functions is shown below. | The form of the PERR macro which calls the GLib logging functions is shown below. |
Revision as of 07:46, 4 September 2018
GnuCash log-levels
The log-levels used in GnuCash are defined in the following table. For some external libraries or modules which implement logging levels defined in those libraries are translated internally to the GnuCash levels as illustrated for the for the Qof module. The Logging MACRO is what you insert into oyur code, where you want to output a message at the appropriate log-level to the log file created as GnuCash is running.
Gnucash Log Level | GLib level strings | QOF_LOG_LEVEL | Logging MACRO | Action after logging |
---|---|---|---|---|
G_LOG_LEVEL_ERROR) | "ERROR", "error" | QOF_LOG_FATAL | FATAL(format,args...) | Aborts the program |
G_LOG_LEVEL_CRITICAL | "CRIT", "crit" | QOF_LOG_ERROR | PERR(format, args...) | Execution continues* |
G_LOG_LEVEL_WARNING | "WARN", "warn" | QOF_LOG_WARNING | WARN(format, args...) | Execution continues |
G_LOG_LEVEL_MESSAGE | "MESSG", "mesg" | QOF_LOG_MESSAGE | g_message(format, args...) | Execution continues |
G_LOG_LEVEL_INFO | "INFO", "info" | QOF_LOG_INFO | PINFO(format, args...) | Execution continues |
G_LOG_LEVEL_DEBUG | "DEBUG", "debug" | QOF_LOG_DEBUG | DEBUG(format, args...) |
GnuCash also defines two similar macros ENTER(format, args...) and LEAVE(format, args...) to record the entry to and exit from a C function. ENTER is placed immediately before any executable code on entry to a function and LEAVE immediately before any exit point from the function. The format and args in all the macros are as defined for a standard printf() function.
* Can be made to exit the program by seting the environment variableG_DEBUG=fatal-warnings gdb ./my-program
g_log_set_always_fatal ();
The form of the PERR macro which calls the GLib logging functions is shown below.
/** Log a serious error */
#define PERR(format, args...) do { \
g_log (log_module, G_LOG_LEVEL_CRITICAL, \
"[%s()] " format, PRETTY_FUNC_NAME , ## args); \
} while (0)
Typical messages produced in a log file by these macros looks like:
* 23:43:24 DEBUG <gnc.import> [gnc_gen_trans_assign_transfer_account_to_selection_cb] Entering for loop over selection
* 23:43:24 DEBUG <gnc.import> [leave gnc_gen_trans_assign_transfer_account_to_selection_cb()]
* 23:43:38 DEBUG <gnc.import.aqbanking> [enter ~/gnucash/import-export/aqb/gnc-plugin-aqbanking.c:main_window_to_account()] main window 0x56164c464300
Return to Logging.