Skip to main content

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 yaclogger

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 !!!")
Yet Another Colorful Logger Example

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.

Colors Example

Contact

For any questions, suggestions, or issues, feel free to reach out

License

This project is licensed under the GNU License - see the LICENSE file for details

Release files for yaclogger 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yaclogger 1.0.0
File Size Uploaded
yaclogger-1.0.0.tar.gz 44.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yaclogger 1.0.0
File Interpreter ABI Platform
yaclogger-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 73.9 kB

Release files / yaclogger-1.0.0.tar.gz

Download URL yaclogger-1.0.0.tar.gz
Size 44.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3f341eff6e12b0d3e11f909c85fa98ded32cd904a39abc361b2e15adab3a6222
BLAKE2b-256 checksum
How to use checksums
b9fd7fa52cd4ddba8eab73447c73d4e9e3fdc72fc8bb71ac03a8862af6f6a4e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / yaclogger-1.0.0-py3-none-any.whl

Download URL yaclogger-1.0.0-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23b21017f6e0be41202cb2df3af85c17b9823c4e40513c0b7ca09e61e8cd810a
BLAKE2b-256 checksum
How to use checksums
ece083130aff923ee1545fdee02d2f0d2bdd69e382c37f29e73fe8bb52324d2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page