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.4.tar.gz (3.3 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.4-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for simple_logging_interceptor-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9dcacc11ff5141a36fcd7bba06ef5749789af96730cc581dfdad38a92753f588
MD5 70f69feb83538a8f6cff51f954aa9501
BLAKE2b-256 8114cc115dd6e481f1ca17db92ccb7939db9cefe8c4c6d37bb4d06d3b5e0f437

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simple_logging_interceptor-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7fdb4783d7c217ff85a3349a48869d1caeec968faaf3248554d9ef3dc927e26f
MD5 21b65de592b8a9366015bb6d3b99fadd
BLAKE2b-256 3dbee15ca81a4f0288a25c6a6f1bb10b09ec5a5674b3b1ffe6e857d0fe0f5c94

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