Skip to main content

A simple Python decorator for logging function calls, arguments, return values, execution time, and exceptions.

Project description

Logging Interceptor

A lightweight Python decorator for logging function calls, arguments, return values, execution time, and exceptions.
Designed to be simple, reusable, and project-agnostic.


📦 Installation

Install from PyPI:

pip install simple-logging-interceptor

🚀 Usage

from simple_logging_interceptor.decorators import simple_logging_interceptor


@simple_logging_interceptor
def add(a, b):
    return a + b


@simple_logging_interceptor
def greet(name, age=None):
    if age:
        return f"Hello {name}, you are {age} years old!"
    return f"Hello {name}!"


print(add(2, 3))
print(greet("Alice"))
print(greet("Bob", age=30))

Example log output:

2025-09-07 12:01:00,123 - INFO - Calling: add with args=(2, 3), kwargs={}
2025-09-07 12:01:00,124 - INFO - Returned from add -> 5 (took 0.01 ms)
2025-09-07 12:01:00,125 - INFO - Calling: greet with args=('Bob',), kwargs={'age': 30}
2025-09-07 12:01:00,125 - INFO - Returned from greet -> Hello Bob, you are 30 years old! (took 0.02 ms)

🧪 Running Tests

This project uses pytest.
To run tests locally:

pip install pytest
pytest

📜 License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_logging_interceptor-0.1.3.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_logging_interceptor-0.1.3-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file simple_logging_interceptor-0.1.3.tar.gz.

File metadata

File hashes

Hashes for simple_logging_interceptor-0.1.3.tar.gz
Algorithm Hash digest
SHA256 fd55c635745753e9ce15e63f7c20779990de485b2462bd0cfd48c9f85f8cbdd8
MD5 c1dafca38dee2e1f576d82f5fc868cbd
BLAKE2b-256 bd1e2345f76fb3f0a4ea96cd55b0402476e60942bffc943824357ac5848cab01

See more details on using hashes here.

File details

Details for the file simple_logging_interceptor-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_logging_interceptor-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e302986486b6f73fc60a50a9fc57dbdba0f90df5d699a1c2a6c36314c43cf7d6
MD5 37307d80bf132df6866a190e0791e6dc
BLAKE2b-256 45db728627140056214e827f49580a8b13eebddb497ae825fd4952eaed7051f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page