A fast and simple logging decorator for Python functions.
Project description
SerpentScribe
serpentscribe is a simple, yet powerful Python logging library designed to make function call logging effortless. It provides a decorator to automatically log the details of function calls, including arguments and return values, to a JSON file.
Features
- Easy to use: Simply decorate your functions to start logging.
- Logs function name, arguments, return values, and timestamp.
- Customizable log file path.
Installation
Install SerpentScribe using pip:
pip install serpentscribe
Usage
To use SerpentScribe, import the log_output decorator and apply it to any function. All inputs and outputs are logged to stdout and if specified, to a JSON file:
from serpentscribe.logger import log_output
# Specify logger level (required) and file path (optional)
@log_output(logger_level="DEBUG", file_path="/path/to/log/file")
def my_function(arg1, arg2):
# Function logic here
return "Result"
Logging Level
A logging level is a required argument when setting the decorator. The following are supported:
| LEVEL | Description |
|---|---|
| DEBUG | Detailed information, typically only of interest to a developer trying to diagnose a problem. |
| INFO | Confirmation that things are working as expected. |
| WARNING | An indication that something unexpected happened, or that a problem might occur in the near future (e.g. ‘disk space low’). The software is still working as expected. |
| ERROR | Due to a more serious problem, the software has not been able to perform some function. |
| CRITICAL | A serious error, indicating that the program itself may be unable to continue running. |
Logging to a File
SerpentScribe will always output to stdout. If a file is specified, then logging will be sent to stdout as well as the specified file.
The log file will have the logs written in JSON format, which is both human-readable and easy to process programmatically. If a path for the log file is not specified, the logs will instead be written to stdout.
Running Tests
To run tests, navigate to the root directory of the project and execute:
python -m unittest discover -s tests
Ensure you have a test suite available in the tests directory.
Contribution
Contributions to SerpentScribe are welcome! Please read the contributing guidelines CONTRIBUTION to get started.
License
SerpentScribe is licensed under the MIT License. See the LICENSE file for more details.
Contact
For any queries or suggestions, feel free to contact the maintainer using Github
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 serpentscribe-0.2-py3-none-any.whl.
File metadata
- Download URL: serpentscribe-0.2-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a909d9d881117f4c0b7edc7e3525a0aa116d02eca7e7c675e40880ce4cb83fb
|
|
| MD5 |
34e113dad46af53ff09139e9ebf638dd
|
|
| BLAKE2b-256 |
0aef4d10b95ed3d085e085221321b8ce03c9738b81220a6d30055758952c7b37
|