log_calls is a Python 3.3+ decorator that can print a lot of useful information
about calls to decorated functions, methods and properties. The decorator can
write to stdout, to another stream or file, or to a logger. log_calls
provides methods for printing your own debug messages to its output stream,
and for easily “dumping” variables and expressions paired with their values.
It can decorate individual functions, methods and properties; but it can also
programmatically decorate callable members of entire classes and class hierarchies,
even of entire modules, with just a single line — which can greatly expedite learning
a new codebase.
In short, log_calls can save you from writing, rewriting, copying, pasting and tweaking a lot of ad hoc, debug-only, boilerplate code — and it can keep your codebase free of that clutter.
For each call to a decorated function or method, log_calls can show you:
These and other features are optional and configurable settings, which can be specified for each decorated callable via keyword parameters, as well as en masse for a group of callables all sharing the same settings. You can examine and change these settings on the fly using attributes with the same names as the keywords, or using a dict-like interface whose keys are the keywords.
log_calls can also collect profiling data and statistics, accessible at runtime, such as:
The package contains two other decorators:
This document describes the decorators’ features and their use. Th e``tests/`` subdirectory of the distribution archive contains many test suites. These contain many additional examples, with commentary. As tests, they provide 96+% coverage.
Built with Sphinx using a tweaked Read the Docs theme.