Skip to main content

A simple module to add color to Python log messages.

Project description

EazyLogger

A simple module to add color to Python log messages.

Table of Contents

Installation

Binary installer is available at the Python Package Index (PyPi).

pip install eazylogger

Logger

Logger(name, msg_fmt="[%(levelname)s] - %(message)s (%(name)s)", info_fmt="%(message)s")

Logger class with color-coded log messages.

Parameters

  • name : str
    • String expression representing the name of the logger class.
  • msg_fmt : str, default [%(levelname)s] - %(message)s (%(name)s)
    • String expression representing how the debug, warning, error, and critical log messages are formatted. Defaults to "[%(levelname)s] - %(message)s (%(name)s)".
  • info_fmt : str, default %(message)s
    • String expression representing how the info and success messages are formatted. Defaults to "%(message)s".

Examples

Basic Example

  1. Import and instantiate Logger class:

    # main.py
    from eazylogger import Logger
    logger = Logger(__name__)
    
  2. Logging methods:

    # main.py
    logger.debug("Example debug message")
    logger.info("Example info message")
    logger.warn("Example warning message")
    logger.error("Example error message")
    logger.critical("Example critical message")
    logger.success("Example success message")
    

Using Parameters

  • name:

    logger = Logger("customName")
    logger.debug("Example debug message with customName")
    
    [DEBUG] - Example debug message with customName (customName)
    
  • msg_fmt:

    • Sets the message format for logger.debug, logger.warn, logger.error, and logger.critical.

    • For full list of keyword arguments see the docs

    logger = Logger(
      __name__,
      msg_fmt="%(asctime)s %(message)s [%(pathname)s]",
    )
    logger.debug("Example debug message with custom msg_fmt")
    
    2000-01-01 12:00:00,000 Example debug message with custom msg_fmt [~\main.py]
    
  • info_fmt

    • Sets the message format for logger.info and logger.success.
    logger = Logger(
      __name__,
      info_fmt="[%(levelname)s] - %(message)s (%(name)s)",
    )
    logger.info("Example info message with custom info_fmt")
    
    [INFO] - Example info message with custom info_fmt (__main__)
    

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

eazylogger-24.9.27.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

eazylogger-24.9.27-py3-none-any.whl (3.7 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