Enhanced Python logger with colorized output, TRACE/PROGRESS levels, and enterprise features (UDP monitoring, file logging, external config) via optional Loguru backend.
Project description
tracecolor
Enhanced Python logger with colorized output, TRACE/PROGRESS levels, and enterprise features. Now powered by Loguru backend with automatic fallback to standard logging for compatibility.
Features
Core Features (v0.5.0 - 100% Backward Compatible)
- Custom TRACE logging level (lower than DEBUG)
- Custom PROGRESS logging level (between DEBUG and INFO)
- Colorized output for different log levels
- Rate-limiting for PROGRESS messages (once per second per call site)
- Simple and clean API
Enhanced Features (v0.6.0 - Automatic with Loguru Backend)
- Loguru Wrapper: tracecolor is now a Loguru wrapper with automatic fallback
- UDP Remote Monitoring: Real-time log streaming over network
- File Logging: Automatic rotation, compression, and retention
- External Configuration: JSON/YAML configuration files
- Multiple Destinations: Simultaneous logging to console, file, and UDP
- Enterprise Performance: Thread-safe, async support, better performance
- 100% Backward Compatibility: Existing code works unchanged, better backend
Installation
Basic Installation (Backward Compatible)
pip install tracecolor
Enhanced Features Installation
pip install tracecolor[enhanced]
Usage
Standard Usage (v0.5.0 Compatible)
from tracecolor import tracecolor
# Create a logger - works exactly like v0.5.0
logger = tracecolor(__name__)
# Log at different levels
logger.trace("Detailed tracing information")
logger.debug("Debugging information")
logger.progress("Progress update information (rate-limited)")
logger.info("General information")
logger.warning("Warning message")
logger.error("Error message")
logger.critical("Critical error")
Enhanced Usage (v0.6.0 Features)
from tracecolor import tracecolor
# Standard usage now automatically uses Loguru backend if available
logger = tracecolor(__name__) # Now powered by Loguru!
logger.info("Better performance, same API")
# Enhanced features explicitly enabled
logger = tracecolor(
name=__name__,
enable_console=True, # Console output (same as original)
enable_udp=True, # UDP remote monitoring
enable_file=True, # File logging with rotation
log_dir="./logs", # Log directory
udp_host="127.0.0.1", # UDP monitoring host
udp_port=9999 # UDP monitoring port
)
# Same API as original tracecolor
logger.info("This message goes to console, file, AND UDP socket")
logger.progress("Progress messages still rate-limited, now with enterprise backend")
# Alternative: convenience function (same result)
from tracecolor import create_enhanced_logger
logger = create_enhanced_logger(__name__, enable_udp=True, enable_file=True, log_dir="logs")
# Monitor logs in real-time (separate terminal)
# python -m tracecolor.monitor
External Configuration
# Create logging_config.json
{
"logging": {
"enable_console": true,
"enable_file": true,
"enable_udp": true,
"log_dir": "./logs",
"udp_host": "127.0.0.1",
"udp_port": 9999,
"log_level": "INFO"
}
}
# Use configuration file
from tracecolor import tracecolor
logger = tracecolor(__name__, config_file="logging_config.json")
UDP Remote Monitoring
Monitor logs in real-time from any application using enhanced features:
# Terminal 1: Run your application with UDP logging
python your_app.py
# Terminal 2: Monitor logs in real-time
python -m tracecolor.monitor
# Or specify host/port
python -m tracecolor.monitor --host 0.0.0.0 --port 8888
# Legacy format also supported
python tracecolor/monitor.py listen 192.168.1.100 9999
The monitor displays formatted output with timestamps, log levels, and messages in real-time.
Migration Guide
From v0.5.0 to v0.6.0
Step 1: Update package (existing code continues to work)
pip install --upgrade tracecolor
Step 2: Install enhanced dependencies (optional)
pip install tracecolor[enhanced]
Step 3: Optionally enable enhanced features where needed
# Before (still works, now with Loguru backend!)
from tracecolor import tracecolor
logger = tracecolor(__name__) # Automatically uses Loguru if available
# Enhanced features when needed
logger = tracecolor(__name__, enable_udp=True, enable_file=True, log_dir="logs")
Step 4: Add external configuration as projects mature
logger = tracecolor(__name__, config_file="logging.json")
Color Scheme
- TRACE: Gray (bold black)
- DEBUG: Cyan
- PROGRESS: Blue
- INFO: Green
- WARNING: Yellow
- ERROR: Red
- CRITICAL: Bold Red
Examples
See the examples/ directory for comprehensive usage examples:
basic_usage.py- Original v0.5.0 functionalityenhanced_features.py- New v0.6.0 features and migration guide
License
MIT
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 tracecolor-0.6.0.tar.gz.
File metadata
- Download URL: tracecolor-0.6.0.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57e757fb65ca8196ed52d1a2f2fbcf9cc73751290c3139bf91b206c28350127c
|
|
| MD5 |
21d189673b8910ff53fa7247f1a21095
|
|
| BLAKE2b-256 |
23599e423e5e82674321798643c82416ed6365f17f3f2c4b6a7e28838cfaf831
|
File details
Details for the file tracecolor-0.6.0-py3-none-any.whl.
File metadata
- Download URL: tracecolor-0.6.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c38e0ef00ef2630eb0789d47d73463b2b4243942260ea4ce2fd7a64a84b30843
|
|
| MD5 |
45dd2b7eadc5aaf934699880d0f1b705
|
|
| BLAKE2b-256 |
aa5de618412f21f0e2097c15fc41723a431d497b6d360eb83490037183d5c531
|