Software contribution and development guide

Tips and Tricks

Python

Logging

A very easy way to manage dynamic logging is by putting a module specific logger in each module and logging to that instance, such as

import logging
logger = logging.getLogger(__name__)

If the above is put into a file package/subpackage/thing.py the __name__ will resolve to package.subpackage.thing. This means that later down the line when using the package, logging for specific modules or subpackages can be tuned individually to track down problems such as

import logging
logger = logging.getLogger('package')
logger.setLevel(logging.WARN)
logger = logging.getLogger('package.subpackage.thing')
logger.setLevel(logging.DEBUG)