Guide
Welcome to the complete guide for pretty-loguru! This will take you from scratch to mastering this powerful logging library.
🎯 Learning Path
🚀 For Beginners
If you are using pretty-loguru for the first time, it is recommended to follow this order:
- Installation - Environment setup and installation steps
- Quick Start - Get started in 5 minutes
- Basic Usage - Core features and basic concepts
🎨 Exploring Features
After mastering the basics, explore the unique features of pretty-loguru:
- Rich Block Logs - Structured visual logs
- ASCII Art Headers - Eye-catching titles
- ASCII Art Blocks - Combining blocks and art
🔧 Advanced Configuration
Dive deep into advanced features and best practices:
- Custom Configuration - Customize logging behavior
- Log Rotation - File management and cleanup
- Performance Optimization - Tuning for production environments
🌐 Application Integration
Integrate pretty-loguru into your projects:
- FastAPI Integration - Web API logging
- Uvicorn Integration - ASGI server logging
- Production Deployment - Enterprise-level deployment guide
📚 Core Concepts
Logger Initialization
pretty-loguru offers multiple initialization methods:
python
from pretty_loguru import create_logger, create_logger
# Method 1: Quick Start (Recommended)
logger = create_logger(
name="guide_demo",
log_path="logs",
level="INFO"
)
# Method 2: Custom Logger
my_logger = create_logger(
name="my_app",
level="DEBUG",
log_path="custom_logs"
)
# Method 3: Advanced Configuration
from pretty_loguru import create_logger
create_logger(
level="INFO",
log_path="logs",
component_name="web_app",
rotation="10MB",
retention="7 days"
)
Log Levels
Supports standard log levels and adds a success
level:
logger.debug()
- Debug messageslogger.info()
- General messageslogger.success()
- Success messages (displayed in green)logger.warning()
- Warning messageslogger.error()
- Error messageslogger.critical()
- Critical errors
Visualization Features
The specialty of pretty-loguru lies in its rich visual output:
python
# Rich Block
logger.block("Title", ["Content 1", "Content 2"], border_style="green")
# ASCII Header
logger.ascii_header("STARTUP", font="slant")
# ASCII Block (combining both)
logger.ascii_block(
"Report",
["Status: Normal", "Time: 10:30"],
ascii_header="REPORT",
ascii_font="small"
)
🎮 Interactive Examples
Want to try it out now? Check out our Example Collection, which includes:
- Basic Usage Examples - Start simple
- Visualization Examples - Showcase all visual features
- FastAPI Examples - Web application integration
- Production Environment Examples - Real-world deployment cases
❓ Having Problems?
- Check the FAQ
- Refer to the API Documentation
- Submit an issue on GitHub
Let's start this elegant logging journey! 🚀