Logging infrastructure

Dragonfly’s logging infrastructure is defined in the dragonfly.log module. It defines sane defaults for the various loggers used in the library as well as functions for setting up logging and tracing.

Adjusting logger levels

Dragonfly’s logger levels can be adjusted much like Python logger levels:

import logging
logging.getLogger("engine").setLevel(logging.DEBUG)

The one caveat is that this must be done after the setup_log() function is called, otherwise the levels you set will be overridden. By default, the function is only called near the top of the module loader scripts (e.g. dragonfly/examples/dfly-loader-wsr.py), not within dragonfly itself.

It is not necessary to call setup_log() at all. Standard Python logging functions such as basicConfig() can be used at the top of module loader scripts instead.

If you are not using dragonfly with a module loader, you will need to set up a logging handler to avoid messages like tho following:

No handlers could be found for logger "typeables"

Functions

setup_log(use_stderr=True, use_file=True, use_stdout=False)[source]

Setup Dragonfly’s logging infrastructure with sane defaults.

Parameters:
  • use_stderr (bool) – whether to output log messages to stderr (default: True).

  • use_file (bool) – whether to output log messages to the ~/.dragonfly.log log file (default: True).

  • use_stdout (bool) – this parameter does nothing andhas been left in for backwards-compatibility (default: False).

setup_tracing(output, limit=None)[source]

Setup call tracing for low-level debugging.

Parameters:
  • output (file) – the file to write tracing messages to.

  • limit (int|None) – the recursive depth limit for tracing (default: None).