Skip to main content

A Python logging utility that generates indented log messages with color-coding for different log levels on the console, and also supports logging to files for better tracking and debugging.

Project description

tidy-logger

License: GPL v3 pre-commit Code style: black GitHub Release GitHub Tag GitHub branch check runs PyPI - tidy-logger PyPI - Implementation PyPI - Format PyPI - Status PyPI - Python Version PyPI - Downloads Conda Version Conda Platform

A repository for a Python logging utility that generates indented log messages with color-coding for different log levels on the console, and also supports logging to files for better tracking and debugging.

[!NOTE] Development for this repository follows the GitFlow workflow.

Installation

To install the tidy-logger package, run the following command:

pip install tidy-logger

Usage

Here’s an example of how to use the tidy-logger utility in a Python project. Start by creating a file named test_module.py, as shown below:

import logging
from tidy_logger import TidyLogger

# Initialize the TidyLogger instance
logger = TidyLogger(app_name="AwesomeApp", app_author="GreatAuthor", log_file_name="journal", console_level=logging.DEBUG)

def some_function() -> None:
    # Example log messages
    logger.debug("This is a debug message - Used for debugging during development.")
    logger.info("This is an info message - General application information.")
    logger.warning("This is a warning message - Something might need attention.")
    logger.error("This is an error message - Something went wrong!")
    logger.critical("This is a critical message - Serious error, action required!")

if __name__ == "__main__":
    some_function()

Run the newly created module using the following command:

python -m test_module.py

Console Output

The logs will appear on the console with color-coded log levels, as shown below:

console output

Options

The environment variable TIDY_LOGGER_LOG_FILE_DIR can be set to specify the log file directory if the log_file_directory argument is not provided during the initialization of TidyLogger. It is recommended to set this environment variable to an absolute path.

Similarly, the environment variable TIDY_LOGGER_LOG_FILE_NAME can be set to set to specify the log file name if the log_file_name argument is not provided.

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

tidy_logger-1.0.0rc1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

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

tidy_logger-1.0.0rc1-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file tidy_logger-1.0.0rc1.tar.gz.

File metadata

  • Download URL: tidy_logger-1.0.0rc1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tidy_logger-1.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 fc48a923822c7d387496fb72f775ebca95013f3c324353e92b6d31e9b6545d44
MD5 63a511a40df59e9e72efcfa1f6536fb1
BLAKE2b-256 80b9fb38f1fdb37b8002d34e3feb76387863812b07aca060912e631d1f11add0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tidy_logger-1.0.0rc1.tar.gz:

Publisher: workflow_publish_to_pypi.yml on fa-vahidi/tidy-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tidy_logger-1.0.0rc1-py3-none-any.whl.

File metadata

  • Download URL: tidy_logger-1.0.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tidy_logger-1.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c7b2c704c2c44e2ef19007d2a8ae7f5f2733f7f3ce5581951f0dc168b58c99b
MD5 c6a62bff195c34150b90746542b0e168
BLAKE2b-256 3d5690b3bb79aa2116a50fd1cfbd98fd3685a372dc30b51bacee60ce14b2e64a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tidy_logger-1.0.0rc1-py3-none-any.whl:

Publisher: workflow_publish_to_pypi.yml on fa-vahidi/tidy-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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