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 details)

Uploaded Source

Built Distribution

eazylogger-24.9.27-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file eazylogger-24.9.27.tar.gz.

File metadata

  • Download URL: eazylogger-24.9.27.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.0

File hashes

Hashes for eazylogger-24.9.27.tar.gz
Algorithm Hash digest
SHA256 8cf9dc40be86b881086e4bc81fee3d933540da5e9ea3f33d991108eb0c8a7db7
MD5 6221e842bc6581057841e490d4c37ce3
BLAKE2b-256 4cd142b0a43cd7fe065770c27c07cb9bca2f8e582fc702bacffd03935b6d22f4

See more details on using hashes here.

File details

Details for the file eazylogger-24.9.27-py3-none-any.whl.

File metadata

File hashes

Hashes for eazylogger-24.9.27-py3-none-any.whl
Algorithm Hash digest
SHA256 9cc4dd444f4cbbdc5eb8de94848f8c2f108e27b2f395bb4e0b2be82c60b30ad7
MD5 c3ea14ed5a3d85676f4510e5a0f614b6
BLAKE2b-256 5918bfbabffd20581b01124f3caaffac06b5ebfea397e70aafe939066d898139

See more details on using hashes here.

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