logdecorator
Move logging code out of your business logic with decorators
What it is and what it does
Logdecorator is a lightweight decorator library that attaches logging to Python functions without embedding log statements in business logic. It provides four main decorators—log_on_start, log_on_end, log_on_error, and log_exception—that trigger at corresponding points in function execution, plus async variants for coroutines. Messages support Python format strings with access to function arguments, return values, and exception objects, keeping code readable while maintaining comprehensive logging coverage.
The library targets developers who want logging instrumentation without the visual noise of try-except blocks or logger calls scattered through their code. With zero runtime dependencies and a simple decorator-based API, it integrates into existing Python projects with minimal friction. It requires Python 3.10 or later and is maintained under a permissive MIT license.
Use it for:
- Wrap API endpoint handlers to log incoming requests and outgoing responses without polluting handler code.
- Decorate data processing functions to track execution flow and timing across a data pipeline.
- Add error logging to utility functions that should fail loudly but keep their implementation clean.
- Instrument async tasks to log lifecycle events (start, completion, failure) in concurrent applications.
- Create audit trails for sensitive operations by logging arguments and results at function boundaries.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Logdecorator provides Python decorators to add logging to functions without cluttering business logic—log at function start, end, or on errors using simple decorator syntax.
Yes, if you want a lightweight, zero-dependency way to add structured logging to functions without embedding log statements in business logic. The dormant maintenance status (last release 545 days ago) is a minor concern for a stable utility library, but verify that async decorator support and format-string behavior match your logging patterns before committing to it in a new project.
Install
logdecorator on PyPI
pip
pip install logdecoratoruv
uv add logdecoratorpoetry
poetry add logdecoratorInstalling logdecorator
Before you install
Low friction installation with no runtime dependencies. Maintenance is dormant—last release was 545 days ago, though the repository remains active with a recent commit on 2025-02-15 and modest community interest (82 stars).
License in practice
MIT license (permissive) means you can use, modify, and distribute logdecorator freely in commercial and private projects with minimal restrictions.
Quickstart
pip install logdecorator
import logging
from logdecorator import log_on_start, log_on_end, log_on_error
@log_on_start(logging.DEBUG, "Starting {url}")
@log_on_end(logging.DEBUG, "Finished {url}")
@log_on_error(logging.ERROR, "Error: {e!r}")
def download(url):
pass
logging.basicConfig(level=logging.DEBUG)
download("https://example.com")
Requires Python 3.10 or later.
Verify before relying
- Whether async decorator support (async_log_on_start, etc.) is fully documented and stable.
- Performance impact of decorator overhead on frequently-called functions.
- Compatibility with popular logging frameworks beyond the standard library.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 545 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 103,146/month — #12,827 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: logdecorator-2.5-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
AutologgingAutologging provides decorators to…
permissive · top 15,000 on PyPI
undecoratedStrips decorators from Python functions,…
permissive · top 15,000 on PyPI
entrypointProvides a decorator to mark functions as entry…
permissive · top 15,000 on PyPI
logfuryLogfury adds automatic method-call tracing to…
permissive · top 15,000 on PyPI
parameter-decoratorsProvides decorators that automatically convert…
copyleft · top 15,000 on PyPI
botoinatorBotoinator lets you attach decorators to boto3…
permissive · top 15,000 on PyPI
python-backoffProvides function decorators for retrying…
permissive · top 5,000 on PyPI
redoRedo provides decorators, functions, and a…
copyleft · top 5,000 on PyPI
wraptwrapt provides a Python module for building…
permissive · top 100 on PyPI
backoffProvides function decorators to automatically…
permissive · top 1,000 on PyPI