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
-
Import and instantiate
Logger
class:# main.py from eazylogger import Logger logger = Logger(__name__)
-
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
, andlogger.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
andlogger.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__)
- Sets the message format for
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.1.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for eazylogger-24.9.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d20fbd83c650da4fa48b71a85e2abf17a50bea8279d25ca4e2f8722bc38c7b96 |
|
MD5 | e5571f59782bc66144395c58d4c10512 |
|
BLAKE2b-256 | 1e4531a1e2d9e955bf264765437529e9ecf1f039967d90d5a38b8add93f7190d |