Skip to main content

hassle-free nicely-formatted console and file logging in Python

Project description

Introduction

This Python module provides an advanced logging setup using rich for console logging and python-json-logger for file logging. It allows for detailed and formatted logging, ideal for applications requiring high-level logging capabilities.

Installation

This module requires the following dependencies:

Usage

Import setup_fancy_logging from the module and configure your logging setup by specifying parameters like base_logger_name, console_log_level, file_log_level, log_file_path, and others.

Example:

import logging
from fancylogging import setup_fancy_logging

log = logging.getLogger("test")

if __name__ == "__main__":
    setup_fancy_logging(
        "test",
        console_log_level=logging.INFO,
        file_log_level=logging.DEBUG,
        file_log_path="logs/test.json",
        file_mode="w",
    )

    log.info("Info message")
    log.debug("Debug message")
    log.warning("Warning message")
    log.error("Error message")
    log.critical("Critical message")
    try:
        raise Exception("Raising a test exception")
    except Exception:
        log.exception("Exception message")

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

fancylogging-0.0.3.tar.gz (4.9 kB view hashes)

Uploaded Source

Built Distribution

fancylogging-0.0.3-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page