Skip to main content

Yet Another Colorful Logger is just another logging utility that adds color to your console log messages.

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

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

yaclogger-1.0.0.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yaclogger-1.0.0-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file yaclogger-1.0.0.tar.gz.

File metadata

  • Download URL: yaclogger-1.0.0.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for yaclogger-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3f341eff6e12b0d3e11f909c85fa98ded32cd904a39abc361b2e15adab3a6222
MD5 2dcfed80653b482da7ed45127637b3bb
BLAKE2b-256 b9fd7fa52cd4ddba8eab73447c73d4e9e3fdc72fc8bb71ac03a8862af6f6a4e9

See more details on using hashes here.

File details

Details for the file yaclogger-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: yaclogger-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for yaclogger-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23b21017f6e0be41202cb2df3af85c17b9823c4e40513c0b7ca09e61e8cd810a
MD5 32dfe9fd51c14d81c6599dcc4fe7d056
BLAKE2b-256 ece083130aff923ee1545fdee02d2f0d2bdd69e382c37f29e73fe8bb52324d2f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page