A simple colored and rotating daily logger
Project description
colorlogx
A simple Python logging helper with colored console output and rotating log files per day.
Perfect for small projects where you want readable logs without heavy dependencies.
Features
- ✅ Colored output for different log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL)
- ✅ Rotating file logs with daily naming (
YYYY-MM-DD_<loggername>.log) - ✅ Optional size-based rotation per file (default
~1 MB) with backups - ✅ Configurable log level, log directory, file size, and backup count
- ✅ Colorized console output can be disabled (
use_colors=False) - ✅ Easy drop-in replacement for
logging.getLogger
Installation
From PyPI (once published):
pip install colorlogx
From TestPyPI (development):
pip install -i https://test.pypi.org/simple/ colorlogx
Usage
from colorlogx import get_logger
# Create a logger
log = get_logger(
"myapp", # logger name
log_level="DEBUG", # default: DEBUG (supports str or int)
log_dir="logs", # default: ./logs
max_bytes=5000*1024, # ~5 MB per file before rotation
backup_count=20, # number of rotated files to keep
use_colors=True # enable colored console output
)
log.debug("This is a debug message")
log.info("This is an info message")
log.warning("This is a warning")
log.error("This is an error")
log.critical("This is critical")
Console output example:
2025-08-18 20:12:30 | myapp | INFO | main.py:12:<module> | This is an info message
2025-08-18 20:12:30 | myapp | ERROR | main.py:13:<module> | This is an error
Log files are written into logs/YYYY-MM-DD_myapp.log.
If the size limit is exceeded on the same day, files roll to YYYY-MM-DD_myapp.log.1, .2, etc.
Configuration Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str | required | Logger name (used in console and log filename) |
log_level |
str/int | DEBUG |
Minimum log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
log_dir |
str | "logs" |
Directory for log files |
max_bytes |
int | 1000*1024 |
Max log file size before rotating |
backup_count |
int | 20 |
Number of rotated files to keep |
use_colors |
bool | True |
Enable/disable colored console output |
Tips
- To disable colors in CI or when piping output, set
use_colors=Falseor rely on your terminal’s color support.import os, logging level = getattr(logging, os.getenv("LOG_LEVEL", "DEBUG").upper(), logging.DEBUG) log = get_logger("myapp", log_level=level)
License
MIT License © 2025 Tobias Auer
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 colorlogx-0.1.0.tar.gz.
File metadata
- Download URL: colorlogx-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d705cfb64a20a646b3445c0c489f14da113a76a1c3b1894fc7d87afbb6a5048
|
|
| MD5 |
ec2e28c765d19e778ae739a87b58cbab
|
|
| BLAKE2b-256 |
e05d937acedaff39b085244c6b729e2efa0c42bcef971b39e8213c0859dc89d3
|
File details
Details for the file colorlogx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: colorlogx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98bf113c67475230373481092d9b8ac08a1f545cf2373df8bb026041b2582257
|
|
| MD5 |
b6d45ef1bb878ade4d1275abf63293cc
|
|
| BLAKE2b-256 |
ac5cbc57f8faf8617a003fb44603bb7a26e1cba06a6cf173cb70ca728521506f
|