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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_logging_interceptor-0.1.4.tar.gz.
File metadata
- Download URL: simple_logging_interceptor-0.1.4.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dcacc11ff5141a36fcd7bba06ef5749789af96730cc581dfdad38a92753f588
|
|
| MD5 |
70f69feb83538a8f6cff51f954aa9501
|
|
| BLAKE2b-256 |
8114cc115dd6e481f1ca17db92ccb7939db9cefe8c4c6d37bb4d06d3b5e0f437
|
File details
Details for the file simple_logging_interceptor-0.1.4-py3-none-any.whl.
File metadata
- Download URL: simple_logging_interceptor-0.1.4-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fdb4783d7c217ff85a3349a48869d1caeec968faaf3248554d9ef3dc927e26f
|
|
| MD5 |
21b65de592b8a9366015bb6d3b99fadd
|
|
| BLAKE2b-256 |
3dbee15ca81a4f0288a25c6a6f1bb10b09ec5a5674b3b1ffe6e857d0fe0f5c94
|