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.27.tar.gz
(3.3 kB
view details)
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cf9dc40be86b881086e4bc81fee3d933540da5e9ea3f33d991108eb0c8a7db7 |
|
MD5 | 6221e842bc6581057841e490d4c37ce3 |
|
BLAKE2b-256 | 4cd142b0a43cd7fe065770c27c07cb9bca2f8e582fc702bacffd03935b6d22f4 |
File details
Details for the file eazylogger-24.9.27-py3-none-any.whl
.
File metadata
- Download URL: eazylogger-24.9.27-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cc4dd444f4cbbdc5eb8de94848f8c2f108e27b2f395bb4e0b2be82c60b30ad7 |
|
MD5 | c3ea14ed5a3d85676f4510e5a0f614b6 |
|
BLAKE2b-256 | 5918bfbabffd20581b01124f3caaffac06b5ebfea397e70aafe939066d898139 |