Skip to main content

Simple coloured logging for Flask and FastAPI apps

Project description

python-coloured-logger

A lightweight Python package that provides clean, coloured logging output for Flask, FastAPI, and any standard Python application.

It extends Python’s built-in logging module with readable coloured console output and simple setup helpers.


Features

  • Coloured console logging
  • Works with standard Python logging
  • Flask integration
  • FastAPI / Uvicorn integration
  • Simple setup API
  • Lightweight with minimal configuration

Installation

Install from PyPI:

pip install python-coloured-logger

Quick Start

from coloured_logger import get_logger

logger = get_logger("my-app")

logger.debug("Debug message")
logger.info("Server started")
logger.success("Database connected")
logger.warning("High memory usage")
logger.error("Request failed")
logger.critical("System crash")

Example output:

[2026-05-27 12:00:00] INFO     Server started
[2026-05-27 12:00:01] SUCCESS  Database connected
[2026-05-27 12:00:02] WARNING  High memory usage
[2026-05-27 12:00:03] ERROR    Request failed

Flask Integration

from flask import Flask
from coloured_logger import setup_logging

app = Flask(__name__)

setup_logging(logger_name="flask.app")

@app.route("/")
def index():
    app.logger.info("Request received")
    return "Hello World"

FastAPI Integration

from fastapi import FastAPI
from coloured_logger import setup_logging

app = FastAPI()

setup_logging(logger_name="uvicorn")

@app.get("/")
async def root():
    return {"message": "Hello World"}

Standard Python Logging

from coloured_logger import setup_logging
import logging

setup_logging()

logger = logging.getLogger("example")

logger.info("Using standard logging")

Environment Variables

Enable or Disable Colours

By default, colours are enabled.

COLOURED_LOGGER_COLOR=True

or for Flask-specific configuration:

FLASK_LOG_COLOR=True

Disable colours:

COLOURED_LOGGER_COLOR=False

Custom Date Format

COLOURED_LOGGER_DATE_FORMAT=%Y-%m-%d %H:%M:%S

or:

FLASK_LOG_DATE_FORMAT=%H:%M:%S

Supported Log Levels

Level Description
debug Debug information
info General information
success Successful operations
warning Warning messages
error Error messages
critical Critical failures

Requirements

  • Python 3.9+
  • Flask (optional)
  • FastAPI / Uvicorn (optional)

License

MIT License


Contributing

Pull requests, issues, and suggestions are welcome.

If you find a bug or want to improve the package, feel free to open an issue or submit a PR.


Links

  • PyPI: https://pypi.org/project/python-coloured-logger/
  • GitHub: https://github.com/Skulldorom/python-coloured-logger

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

python_coloured_logger-0.2.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

python_coloured_logger-0.2.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file python_coloured_logger-0.2.0.tar.gz.

File metadata

  • Download URL: python_coloured_logger-0.2.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for python_coloured_logger-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e78ba969c333676b1896dfe2e5ebb9791f303293c6472b3b624971ca5a7bcec4
MD5 a9820e4804d37da2eb3287c3e8d60bfd
BLAKE2b-256 e1fd3bc9ba34a90127fc22879b3badd15e5735781675eab0069292f6c08c8ecc

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_coloured_logger-0.2.0.tar.gz:

Publisher: publish.yml on Skulldorom/coloured-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_coloured_logger-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_coloured_logger-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89cbaa027396c769645287bdfeee6698bab6e7aed73a22e4a7982a6def6327d1
MD5 e41b72057f3c11308aadae3fc7f1ee01
BLAKE2b-256 e6144de7ec4a7866b0e7a188f508552e857177e8bbc9f25b95864e3aecfa758e

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_coloured_logger-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Skulldorom/coloured-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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