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.2.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.2-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file tidy_logger-1.0.2.tar.gz.

File metadata

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

File hashes

Hashes for tidy_logger-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8ef2cb72f406a64b004665575abad1b528d0b8b2e873dece61317ceb19e9ec4d
MD5 949daf7d99626d3e8e85d3db77b5595c
BLAKE2b-256 ad3afb9c6a6edaf48c6d5aeba87a94263a9ba9213d5f69bcfcbe483d4a22eea0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tidy_logger-1.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: tidy_logger-1.0.2-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.12

File hashes

Hashes for tidy_logger-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd94e154f9dafc054a35240cb13f42edf24252cf0dee19b22225d6c0fb8bfd12
MD5 2b16cc1542385ea8ecce0a9bca5bdea4
BLAKE2b-256 ec3ee2dbf1c95acf86d79a48942c2bcadb3faa66ebbbdb60e2671bc5f328a1c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tidy_logger-1.0.2-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