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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_coloured_logger-0.1.1.tar.gz.
File metadata
- Download URL: python_coloured_logger-0.1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85db43ed87ae2cb70ad3ee911992ebc070ef5d071e01bb1a20b8ef6fd92dee04
|
|
| MD5 |
791a1972647f4ebf50c65447cb17fdb3
|
|
| BLAKE2b-256 |
3e2729afd8d79329332361e49200bb9a0804bb4da44071e91bab048f7571802c
|
Provenance
The following attestation bundles were made for python_coloured_logger-0.1.1.tar.gz:
Publisher:
publish.yml on Skulldorom/coloured-logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_coloured_logger-0.1.1.tar.gz -
Subject digest:
85db43ed87ae2cb70ad3ee911992ebc070ef5d071e01bb1a20b8ef6fd92dee04 - Sigstore transparency entry: 1641686442
- Sigstore integration time:
-
Permalink:
Skulldorom/coloured-logger@21791e8746d56a3855110b34dd93af40a6e46984 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Skulldorom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@21791e8746d56a3855110b34dd93af40a6e46984 -
Trigger Event:
push
-
Statement type:
File details
Details for the file python_coloured_logger-0.1.1-py3-none-any.whl.
File metadata
- Download URL: python_coloured_logger-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b61258034e6ecb02e131d937bd118265e3027df8ae3eabbc6ab0189b7917db90
|
|
| MD5 |
be43fca66bccabfdb56d5dc0b280ab27
|
|
| BLAKE2b-256 |
fcfcfc622a09edb26255b20d86d97962ab9304e9a4890315cf25a0211d079a30
|
Provenance
The following attestation bundles were made for python_coloured_logger-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Skulldorom/coloured-logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_coloured_logger-0.1.1-py3-none-any.whl -
Subject digest:
b61258034e6ecb02e131d937bd118265e3027df8ae3eabbc6ab0189b7917db90 - Sigstore transparency entry: 1641686527
- Sigstore integration time:
-
Permalink:
Skulldorom/coloured-logger@21791e8746d56a3855110b34dd93af40a6e46984 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Skulldorom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@21791e8746d56a3855110b34dd93af40a6e46984 -
Trigger Event:
push
-
Statement type: