Colorama/HTML Capable Logger

1.6.0 · maintenance · verified Fri Apr 17

cpylog is a simple, pure Python logging library designed to provide colorful console output using Colorama and rich HTML output capabilities (via Pygments). It offers a straightforward API to configure and manage loggers with various handlers and formatters. The current version is 1.6.0. The library appears to be in maintenance mode, with its last release in 2021, indicating a stable but not actively developed project.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up `cpylog` for console output using `basic_config` and then add an `HTMLFileHandler` to simultaneously log messages to an HTML file. It covers different logging levels.

from cpylog.config import basic_config
from cpylog import get_logger, HTMLFileHandler
import os

# Configure basic logging to console (INFO level by default)
basic_config() 

logger = get_logger("my_app")
logger.info("This is an informational message to console.")
logger.warning("A warning message.")

# Configure and add an HTML file handler
html_handler = HTMLFileHandler("app_log.html")
logger.addHandler(html_handler)
logger.info("This message will go to console and app_log.html.")
logger.error("An error occurred, see details in HTML file.")

# To demonstrate basic logging with different levels
logger.debug("This is a debug message (won't show by default with basic_config).")
logger.critical("Critical error! System might be down.")

print("Check app_log.html for HTML output.")

# Clean up the generated file (optional, for demonstration)
# try:
#     os.remove("app_log.html")
# except OSError:
#     pass

view raw JSON →