Examples¶
Welcome to the Logly examples! This section contains comprehensive, runnable examples that demonstrate all major features of the Logly logging library.
📋 Table of Contents¶
🏗️ Getting Started Examples¶
- Basic Console Logging - Start here! Simple console output with colors and formatting
- Colored Logging - Default colors, custom colors, and FAIL level (NEW v0.1.5)
- Per-Level Controls - Control console output, timestamps, and colors per log level
- Template String Formatting - Custom log message formatting with placeholders
📁 File & Storage Examples¶
- File Logging with Rotation - Time-based and size-based log rotation
- JSON Logging - Structured JSON output for log analysis
- Multi-Sink Setup - Multiple outputs with independent filtering
🔧 Advanced Features¶
- Async Logging - Background writing for high-performance applications
- Context Binding - Add persistent context to all log messages
- Exception Handling - Automatic exception logging and traceback capture
- Color Callback Styling - Custom color styling with callback functions
- Auto-Sink Levels - ✨ NEW in v0.1.5: Declarative per-level sink configuration
🚀 Quick Start¶
Copy and run any example to see Logly in action:
# Clone the repository
git clone https://github.com/muhammad-fiaz/logly.git
cd logly
# Install dependencies
pip install -e .
# Run an example
python examples/basic_console.py
💡 Tips for Learning¶
- Start Simple: Begin with Basic Console Logging to understand the fundamentals
- Build Up: Each example builds on previous concepts
- Experiment: Modify the code and see what happens
- Combine Features: Mix techniques from different examples
📚 Related Documentation¶
- Quick Start Guide - Get up and running in 5 minutes
- API Reference - Complete method documentation
- Configuration Guide - Advanced configuration options
- Production Deployment - Production best practices