Skip to main content

A fast, simple, and yet powerful Python logging library designed to make function call logging effortless. No longer do you have to instantiate logging multiple times within a function or class. This module provides a simple decorator to automatically log the details of function calls, including arguments and return values to stdout and optionally to a JSON file specified.

Project description

SerpentScribe

serpentscribe is a simple, yet powerful Python logging library designed to make function call logging effortless. No longer do you have to instantiate logging multiple times within a function or class. This module provides a simple decorator to automatically log the details of function calls, including arguments and return values to stdout and optionally to a JSON file specified.

Features

  • Easy to use: Simply decorate your functions to start logging.
  • Logs function name, arguments passed, return values, and timestamp.
  • Customizable log file path when exporting to a file.

Installation

Install SerpentScribe using pipenv:

pipenv install serpentscribe

or if you haven't graduated to PIPENV yet, (you probably should) you can install 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

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

serpentscribe-0.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file serpentscribe-0.3-py3-none-any.whl.

File metadata

  • Download URL: serpentscribe-0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for serpentscribe-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 366ad408d8ce9f68709d9d19d3be9d4a9fa3d6597e4e5d5ed298d1caa90552ed
MD5 e6bbd67b1bc8725ed97dd98f4c0676a8
BLAKE2b-256 b1f0e0b78a900dfb0b62842249f18dd8f1984a190883e9ed18f6403acc9dd40a

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