15. debug — Control debug and verbosity output.

15.1. Classes defined in module debug

class debug.DEBUG(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

A class with debug items.

This class holds the defined debug items as attributes. Each debug topic is a binary value with a single bit set (a power of 2). Debug items can be combined with & (AND), | (OR) and ^ (XOR). Two extra values are defined: NONE switches off all debugging, ALL activates all debug items.

Examples

List all existing debug items:

>>> for v in DEBUG:
...     if v not in (DEBUG.NONE, DEBUG.ALL):
...         print(v)
DEBUG.INFO
DEBUG.WARNING
DEBUG.CONFIG
DEBUG.DETECT
DEBUG.HELP
DEBUG.MEM
DEBUG.SCRIPT
DEBUG.GUI
DEBUG.MENU
DEBUG.DRAW
DEBUG.CANVAS
DEBUG.OPENGL
DEBUG.LIB
DEBUG.MOUSE
DEBUG.APPS
DEBUG.IMAGE
DEBUG.PICK
DEBUG.MISC
DEBUG.ABQ
DEBUG.WIDGET
DEBUG.PROJECT
DEBUG.WEBGL
DEBUG.MULTI
DEBUG.LEGACY
DEBUG.PLUGIN
DEBUG.UNICODE
DEBUG.FONT
DEBUG.PGF
DEBUG.VTK
DEBUG.DOCTEST
>>> print((DEBUG.INFO | DEBUG.CONFIG | DEBUG.LIB) & DEBUG.ALL)
DEBUG.INFO|CONFIG|LIB
classmethod item(name)[source]

Convert a string to a DEBUG item

The string is case insensitive.

Raises:

ValueError – If the name is not a DEBUG item.

classmethod level(names)[source]

Return the combined debug level for a list of debug items

Raises:

ValueError – If any of the names is not a DEBUG item.

15.2. Functions defined in module debug

debug.debugon(topics)[source]

Return True if any of specified debug topics is in options.debuglevel.

Parameters:

topics (DEBUG) – A DEBUG topic or any combination of them.

Returns:

bool – True if any of the flags in topics is in options.debuglevel. This is effectively the bool value of the binary AND of topics and options.debuglevel.

Note

Testing if flag1 or flag2 is as easy as debugon(flag1 | flag2) If you need to test that multiple flags are in options.debuglevel, use debugon(flag1) & debugon(flag2)

Examples

>>> pf.options.debuglevel = DEBUG.INFO | DEBUG.OPENGL | DEBUG.GUI | DEBUG.MENU
>>> debugon(DEBUG.WARNING | DEBUG.OPENGL)
True
>>> debugon(DEBUG.WARNING & DEBUG.OPENGL)
False
>>> debugon(DEBUG.WARNING & DEBUG.OPENGL | DEBUG.GUI)
True
>>> debugon(DEBUG.OPENGL) & debugon(DEBUG.GUI)
True
>>> debugon(DEBUG.ALL)
True
>>> pf.options.debuglevel = DEBUG.NONE
>>> debugon(DEBUG.ALL)
False
debug.verbosity(verbose)[source]

Check that verbosity is equal or higher than given value