Just another Colorful Logger with my personal customizations to be used in any python script.
Project description
Yet Another Colorful Logger
Description
Yet Another Colorful Logger is just another Python logging utility that adds color to your console log messages. This module is already configured, not requiring any setup. Simply install it and integrate into your Python projects. However, if you want to customize it, you can do it as well.
For customizing the logger, you can change the colors, the format, and the log level. For more details, check the Customization section.
This module was created for personal use, but feel free to use it in your projects as well. Also, feel free to customize it according to your needs.
Any issues, suggestions, or questions, please feel free to reach out.
Installation
To install Yet Another Colorful Logger, use pip
:
pip install yet-another-colorful-logger
Usage
To start using the logger is pretty forward. Just import it and create a logger instance:
from yaclogger import YACLogger
# Create a logger instance
logger = YACLogger(name="my_logger")
# Log messages with different severity levels
logger.debug("This is a debug message !!!")
logger.info("This is an info message !!!")
logger.warning("This is a warning message !!!")
logger.error("This is an error message !!!")
logger.critical("This is a critical message !!!")
Customization
For customizing the colors, you can pass a dictionary
as the log_colors parameter to the YACLogger
constructor. The dictionary must contain the log level as the key and the color as value, both in strings. In case you want to use a background color, you can pass the color name with the prefix bg_
, separated by a comma.
Example 1:
If you want to change the background only for the ERROR
log level, you can pass the following dictionary:
my_custom_log_colors = {
"ERROR": "black,bg_red"
}
yaclogger = YACLogger(name="my_logger", log_colors=my_custom_log_colors)
Example 2:
If you want to change the background only for DEBUG
and CRITICAL
log level, you can pass the following dictionary:
my_custom_log_colors = {
"DEBUG": "green,bg_white",
"CRITICAL": "red"
}
yaclogger = YACLogger(name="my_logger", log_colors=my_custom_log_colors)
Example 3:
If you want to change the color for all log levels, you can pass the following dictionary:
my_custom_log_colors = {
"DEBUG": "light_blue",
"INFO": "green",
"WARNING": "cyan",
"ERROR": "purple",
"CRITICAL": "black,bg_white"
}
yaclogger = YACLogger(name="my_logger", log_colors=my_custom_log_colors)
Available Colors
black | blue | purple | cyan |
red | white | light_black | light_red |
green | light_green | light_yellow | light_blue |
yellow | light_purple | light_cyan | light_white |
Note: In some terminals, the foreground colors can have the same representation as the background colors, even both codes being different on the code. So, if you use the same color for both foreground and background in the same log level, you may not be able to see the message.
Contact
For any questions, suggestions, or issues, feel free to reach out:
- GitHub: Wagner Cotta
License
This project is licensed under the GNU License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for yet_another_colorful_logger-1.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a42259a46c17abf9e79d099e39f73c448a47aa48123965167f8eb578cb7a0a7 |
|
MD5 | da30af2ae879484af7fcf2f65d7c6642 |
|
BLAKE2b-256 | ab797a9ad03f8a08f0a050965bd83ee5b12a111c88ad24079546c00d3caa1d29 |
Hashes for yet_another_colorful_logger-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1808a42aaae6f8f6cba54170d2f4f43f4b48631037d78ebad4c95e085722de80 |
|
MD5 | 4094da737611af95ac46019656858eae |
|
BLAKE2b-256 | ec9832f4c1b5cbed2e34e23c4e4780d37c960fe43aec4745fb351c4a974715e4 |