🌈 richcolorlog – Beautiful, Powerful & Multi-Output Logging for Python
✨ Log like a pro with emoji icons, syntax highlighting, custom log levels, and support for console, file, RabbitMQ, Kafka, ZeroMQ, Syslog, and databases — all in one package!
🚀 Features
-
✅ Rich Console Output with colors, backgrounds, and emoji icons per log level
-
🎨 Syntax Highlighting for code snippets (Python, SQL, JSON, etc.) via
lexer='python' -
🎯 Custom Log Levels:
EMERGENCY,ALERT,NOTICE,FATAL(Syslog-compliant) -
📦 Multi-Handler Support:
- 🖥️ Console (Rich + ANSI fallback)
- 📄 File (with level-based formatting)
- 🐇 RabbitMQ
- 📡 Kafka
- 📡 ZeroMQ
- 📡 Syslog
- 🗄️ PostgreSQL / MySQL / MariaDB / SQLite
-
🧪 Jupyter/IPython Friendly (no async warnings!)
-
🧩 Full LogRecord Template Support:
%(asctime)s,%(funcName)s,%(threadName)s,%(icon)s, etc. -
🔁 Smart Timestamp: Repeated timestamps are hidden (like
RichHandleroriginal) -
🎨 Custom Colors: Set color per level (
info_color,error_color, etc.) -
⚙️ Highly Configurable:
icon_first,level_in_message,show_background, etc. -
🚀 Easy to use - Simple setup with sensible defaults
-
⚡ Zero required dependencies (only
richfor Rich mode; brokers optional) -
🎨 Support any terminal - with ansi color Fallback
📦 Installation
Install from PyPI:
pip install richcolorlog
💡 Optional: Install extras for message brokers:
pip install richcolorlog[rabbitmq,kafka,zmq,db]
Or install from source:
git clone https://github.com/cumulus13/richcolorlog
cd richcolorlog
pip install -e .
Documentations
🧪 Quick Start
Basic Usage (Rich Console)
>>> from richcolorlog import setup_logging
>>> logger = setup_logging(
name="myapp",
show_background=True,
show_icon=True,
icon_first=True
)
>>> logger.emergency("This is an emergency message")
logger.alert("This is an alert message")
logger.critical("This is a critical message")
logger.error("This is an error message")
logger.warning("This is a warning message")
logger.notice("This is a notice message")
logger.info("This is an info message")
logger.debug("This is a debug message")
>>> # output
🆘 [10/04/25 14:12:07] EMERGENCY This is an emergency message
🚨 [10/04/25 14:12:07] ALERT This is an alert message
💥 [10/04/25 14:12:07] CRITICAL This is a critical message
❌ [10/04/25 14:12:07] ERROR This is an error message
⛔ [10/04/25 14:12:07] WARNING This is a warning message
📢 [10/04/25 14:12:07] NOTICE This is a notice message
🔔 [10/04/25 14:12:07] INFO This is an info message
🪲 [10/04/25 14:12:07] DEBUG This is a debug message
>>> FORMAT = "%(icon)s %(asctime)s - %(name)s - %(process)d - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
>>> logger = setup_logging(show_background=True, format_template=FORMAT, name="TEST")
>>> code = """
def hello():
print("Hello World")
"""
>>> logger.info(code, lexer='python')
>>> #output
🔔 [10/04/25 15:12:34] TEST 15448 INFO
def hello():
print("Hello World")
>>> logger.debug("SELECT * FROM users", lexer="sql") # Syntax highlighted!
>>> #output
🪲 [10/04/25 15:12:35] TEST 15448 DEBUG
SELECT * FROM users
With Custom Format Template
template = "%(asctime)s | %(levelname)s | %(name)s | %(funcName)s() | %(message)s"
logger = setup_logging(
name="api",
format_template=template,
show_background=False
)
logger.notice("User logged in successfully 🔑")
Custom Format Template + Icon in Template
FORMAT = "%(icon)s %(asctime)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
logger = setup_logging(
name="TEST",
format_template=FORMAT,
icon_first=True, # Icon always at start (overrides template position)
omit_repeated_times=True # Hide repeated timestamps
)
logger.info("Hello world")
# Output:
# 🔔 [10/06/25 15:30:00] INFO - Hello world (test.py:10)
# 🔔 INFO - Another message (test.py:11)
Show Level in Message (level_in_message=True)
logger = setup_logging(level_in_message=True)
logger.info("This is a message")
# Output: INFO - This is a message
Simple Logger (No Rich, for Jupyter)
from richcolorlog import setup_logging_custom
logger = setup_logging_custom(
name="notebook",
show_icon=True,
icon_first=False,
show_background=False
)
logger.info("Running analysis in Jupyter 📊")
🎯 Advanced Examples
🔌 Send Logs to Kafka & File Logging
logger = setup_logging(
name="producer",
log_file=True,
log_file_name="app.log",
kafka=True,
kafka_host="localhost",
kafka_port=9092,
kafka_topic="app-logs",
level="DEBUG"
)
logger.alert("Critical system event! 🚨")
🗄️ Log to PostgreSQL
logger = setup_logging(
db=True,
db_type="postgresql",
db_host="localhost",
db_name="logs",
db_user="admin",
db_password="secret"
)
logger.emergency("Database connection lost!")
🎨 Custom Colors per Level
logger = setup_logging(
info_color="#00FFAA",
error_color="bold red on #111111",
warning_color="yellow",
show_background=True
)
logger.info("Custom color!")
logger.error("Custom background!")
🧠 Custom Log Levels
logger.notice("New user registered 📢") # Custom level 25
logger.fatal("Fatal error — shutting down 💀") # Level 55
logger.alert("Immediate action required! 🚨") # Level 59
🧠 Custom Log Levels (Correct Location!)
# File: test.py
logger = setup_logging(name="test")
logger.emergency("System down!") # Shows: test.py:5 (not logger.py!)
import logging
logger = logging.getLogger("INHERITANCE")
from richcolorlog import RichColorLogHandler
handler = RichColorLogHandler()
logger.handlers.clear()
logger.addHandler(handler)
logger.propagate = False
logger.emergency("RGBME v0.13.2 - 128x64 Matrix | 1x1 Chain | 12px per LED (REAL) | BrowserAdapter")
logger.alert("RGBME v0.13.2 - 128x64 Matrix | 1x1 Chain | 12px per LED (REAL) | BrowserAdapter")
logger.critical("RGBME v0.13.2 - 128x64 Matrix | 1x1 Chain | 12px per LED (REAL) | BrowserAdapter")
logger.error("RGBME v0.13.2 - 128x64 Matrix | 1x1 Chain | 12px per LED (REAL) | BrowserAdapter")
logger.warning("RGBME v0.13.2 - 128x64 Matrix | 1x1 Chain | 12px per LED (REAL) | BrowserAdapter")
logger.notice("RGBME v0.13.2 - 128x64 Matrix | 1x1 Chain | 12px per LED (REAL) | BrowserAdapter")
logger.debug("RGBME v0.13.2 - 128x64 Matrix | 1x1 Chain | 12px per LED (REAL) | BrowserAdapter")
🛠️ Configuration Options
| Parameter | Description | Default |
|---|---|---|
show_icon |
Show emoji icons | True |
icon_first |
Icon before timestamp | True |
format_template |
Log format (supports %(icon)s) |
None |
level_in_message |
Prefix message with "LEVEL - " |
False |
omit_repeated_times |
Hide repeated timestamps | True |
show_background |
Enable background colors | True |
..._color |
Custom color per level (info_color, error_color, etc.) |
Default |
All RichHandler args |
tracebacks_show_locals, keywords, highlighter, etc. |
Fully supported |
✅ If
format_templatecontains%(icon)s, the icon is still controlled byicon_first— no duplicates.
🦝 Available Lexers
You can use any lexer supported by Pygments for syntax highlighting:
"python"- Python code"javascript"- JavaScript code"sql"- SQL queries"json"- JSON data"yaml"- YAML configuration"bash"- Shell scripts- And many more...
🐇 Custom Log Levels
richcolorlog adds several custom log levels above the standard CRITICAL level:
| Level | Numeric Value | Description |
|---|---|---|
| NOTICE | 55 | Informational messages |
| ALERT | 60 | Alert conditions |
| CRITICAL | 65 | Critical conditions |
| FATAL | 70 | Fatal errors |
| EMERGENCY | 75 | System is unusable |
🧩 Supported Log Record Fields in Templates
You can use any standard LogRecord field in your format_template:
%(asctime)s → 2025-10-03 14:30:00
%(name)s → myapp
%(levelname)s → INFO
%(message)s → Your log message
%(filename)s → app.py
%(lineno)d → 42
%(funcName)s → main
%(process)d → 12345
%(thread)d → 67890
%(module)s → app
%(pathname)s → /path/to/app.py
%(created)f → 1728000000.123
%(msecs)d → 123
%(relativeCreated)d → 456
%(processName)s → MainProcess
%(threadName)s → Thread-1
%(icon)s → 🐞 (auto-injected)
✅ Custom fields from
extra={}are also supported!
🌐 Compatibility
- ✅ Python 3.8+
- ✅ Jupyter Notebook / IPython (auto-detects and disables async features)
- ✅ Terminals (Windows, macOS, Linux)
- ✅ Docker / CI Environments (falls back to ANSI if needed)
📚 Why Use richcolorlog?
| Feature | Standard logging |
rich |
richcolorlog |
|---|---|---|---|
| Emoji Icons | ❌ | ❌ | ✅ |
Custom Levels (NOTICE, ALERT) |
❌ | ❌ | ✅ |
| Syntax Highlighting | ❌ | ❌ | ✅ |
| Multi-Output (File + Kafka + DB) | Manual | ❌ | ✅ |
| Template + Icon | ❌ | Limited | ✅ |
| Accurate File/Line | ✅ | ❌ | ✅ |
| Jupyter Safe | ❌ | ⚠️ | ✅ |
| Repeated Timestamps | ❌ | ✅ | ✅ |
| Custom Format Templates | ✅ | Limited | ✅ + icon support |
🙏 Acknowledgements
- Built on top of
richby Will McGugan with ansi color Fallback if no rich installed - Icons from EmojiOne
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT © Hadi Cahyadi
🔗 Links
- 📦 PyPI: https://pypi.org/project/richcolorlog/
- 💻 GitHub: https://github.com/cumulus13/richcolorlog
- 📧 Author: cumulus13@gmail.com
💬 Made with ❤️ for developers who love beautiful, informative logs!
⭐ Star the repo if you find it useful!
author
Metadata
Release files for richcolorlog 1.44.33
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| richcolorlog-1.44.33.tar.gz | 488.3 kB | Without provenance | Details for richcolorlog-1.44.33.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| richcolorlog-1.44.33-py3-none-any.whl | Python 3 | none | any | Details for richcolorlog-1.44.33-py3-none-any.whl |
Total release size: 755.4 kB
Release files / richcolorlog-1.44.33.tar.gz
| Download URL | richcolorlog-1.44.33.tar.gz |
|---|---|
| Size | 488.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3602175df5644bad14829ba487a89a7e1f81f2a69727e0667c3134c7a05a4e8e
|
|
BLAKE2b-256 checksum How to use checksums |
436374e6d440329fae2ed64dcff8b9ad00e117b005500f4cbbf604018ca3f341
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / richcolorlog-1.44.33-py3-none-any.whl
| Download URL | richcolorlog-1.44.33-py3-none-any.whl |
|---|---|
| Size | 267.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43e498a22947224a64c280c75b9711be178305e2c99f2ad4dbe8fdb1955be4aa
|
|
BLAKE2b-256 checksum How to use checksums |
58478c1f29fc84b3246970b1ac390aad2a72abc2cdb5df79fb96d49426ed04e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for richcolorlog 1.44.33
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.