Changes

Jump to: navigation, search

Logging system

327 bytes added, 23:46, 11 May 2020
m
If debugging is enabled
The GRAMPS Gramps Logging System is based on the [httphttps://docs.python.org/liblibrary/module-logging.html Python]s logging facility.
==Handler subclasses==
==Handler instances==
Currently there is one instance of each of the above Handler classes in GRAMPSGramps. Additionally there's also a StreamHandler() defined with <tt>sys.stderr</tt> as output stream for debugging purposes. All of these Handlers are attached to the root logger, thus active for any later defined logger.
The RotateHandler, GtkHandler and StreamHandler are all instantiated in <tt>gramps.py</tt> (setup_logging), while Warnhandler is instantiated in <tt>DisplayState.py</tt> (DisplayState.__init__). Rotatehandler is attached also to GtkHandler for the purpose described in GtkHandler description. Each Handler instance has a custom formatter assigned.
{| {{prettytable}}class="wikitable sortable"
|+Handler instance parameters
|-
The usage of the switch is quite simple:
python grampsGramps.py -d "name_of_the_logger"
or:
python grampsGramps.py --debug="name_of_the_logger"
The name of the root logger is an empty string, thus e.g. <tt>--debug=""</tt> will enable all debug logs.
<blockquote>'''{{man warn|Note!''' |The argument of the switch is <u>not</u> optional.</blockquote>}}
==So how logging works in GRAMPS Gramps after all?==
===If debugging is not enabled===
* all WARNING and above level logs will be buffered by WarnHandler and can be seen by pressing the warn_button within 3 minutes after the latest log is received.
_LOG.debug('a debug message')
:To see this message in a terminal, one starts GRAMPS Gramps with the debug option followed by the debug logger one wants to see:
python src/gramps.py -d '.pageview'
:Strings need to be double-quoted on Windows, this is the Windows equivalent of the above command (with the "all in one installer" executed from "C:\Program Files\GrampsAIO64-5.1.2"):
 
grampsw.exe -d ".pageview"
 
:On Windows the log output goes into the file "%AppData%\gramps\Gramps51.log" (which is cleared every time the app restarts).
[[Category:Developers/Reference]]
[[Category:Developers/Tutorials]]
[[Category:Developers/General]]
14
edits

Navigation menu