CLI Reference¶
Command-line interface documentation for Ezpl logging framework.
Overview¶
The Ezpl CLI provides comprehensive tools for managing configuration, viewing logs, and performing various operations from the command line.
Features¶
- 📊 Log Management: View, search, tail, export, and clean log files
- ⚙️ Configuration: Get, set, and reset configuration values
- 🔍 Statistics: Analyze log statistics with temporal distribution
- 📤 Export: Export logs to JSON, CSV, or TXT formats
- 🌍 Environment: Manage environment variables
Quick Start¶
Installation¶
The CLI is automatically available when Ezpl is installed:
Basic Usage¶
# Display help
ezpl --help
# View logs
ezpl logs view --lines 50
# Search logs
ezpl logs search --pattern "error" --level ERROR
# Get configuration
ezpl config show
# Set configuration
ezpl config set log_level DEBUG
# Display version
ezpl version
Command Categories¶
| Category | Commands | Description |
|---|---|---|
| Logs | view, search, stats, tail, list, clean, export | Log file operations |
| Config | show, set, reset, export | Configuration management |
| Info | version, info | Package information |
Logs Commands¶
ezpl logs view¶
View log file contents with optional filtering.
Options:
--file, -f PATH: Path to log file (default: from config)--lines, -n N: Number of lines to display (default: 50)--level, -l LEVEL: Filter by log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)--follow, -F: Follow log file (liketail -f)
Examples:
# View last 100 lines
ezpl logs view --lines 100
# View errors only and follow
ezpl logs view --level ERROR --follow
# View specific file
ezpl logs view --file /path/to/app.log
ezpl logs search¶
Search log entries using regex patterns.
Options:
--pattern, -p PATTERN: Search pattern (regex supported) [required]--file, -f PATH: Path to log file (default: from config)--level, -l LEVEL: Filter by log level--case-sensitive, -c: Case-sensitive search
Examples:
# Search for errors or exceptions
ezpl logs search --pattern "error|exception"
# Case-sensitive search in ERROR level
ezpl logs search --pattern "Database" --level ERROR --case-sensitive
ezpl logs stats¶
Display statistics about log files.
Options:
--file, -f PATH: Path to log file (default: from config)--format, -F FORMAT: Output format:table(default) orjson
Examples:
# Display stats in table format
ezpl logs stats
# Export stats as JSON
ezpl logs stats --format json > stats.json
Output includes:
- Total lines
- Log level distribution
- File size
- Date range
- Error rate
ezpl logs tail¶
Display the last lines of a log file.
Options:
--file, -f PATH: Path to log file (default: from config)--lines, -n N: Number of lines to display (default: 20)--follow, -F: Follow log file continuously
Examples:
ezpl logs list¶
List available log files.
Options:
--dir, -d PATH: Directory to search (default: from config)
Examples:
# List log files in default directory
ezpl logs list
# List log files in specific directory
ezpl logs list --dir /var/log/myapp
ezpl logs clean¶
Clean old or large log files.
Options:
--file, -f PATH: Specific file to clean--days, -d N: Delete files older than N days--size, -s SIZE: Delete files larger than SIZE (e.g., '100MB')--confirm, -y: Skip confirmation prompt
Examples:
# Clean files older than 30 days
ezpl logs clean --days 30
# Clean files larger than 500MB (no confirmation)
ezpl logs clean --size 500MB --confirm
ezpl logs export¶
Export log file to different formats.
Options:
--file, -f PATH: Path to log file (default: from config)--format, -F FORMAT: Export format:json(default),csv, ortxt--output, -o PATH: Output file path (default: stdout)
Examples:
# Export to JSON
ezpl logs export --format json --output logs.json
# Export to CSV
ezpl logs export --format csv --output logs.csv
# Export to stdout
ezpl logs export --format json
Configuration Commands¶
ezpl config show¶
Display current configuration.
Options:
--env, -e: Also show environment variables
Examples:
# Show current configuration
ezpl config show
# Show with environment variables
ezpl config show --env
ezpl config set¶
Set a configuration value.
Options:
KEY: Configuration keyVALUE: Configuration value--env, -e: Also set as environment variable
Available Keys:
log_level: Global log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)log_file: Log file nameprinter_level: Console output levelfile_logger_level: File logging levellog_rotation: Rotation setting (e.g., "10 MB", "1 day")log_retention: Retention period (e.g., "7 days")log_compression: Compression format (e.g., "zip", "gz")indent_step: Indentation step sizeindent_symbol: Symbol for indentationbase_indent_symbol: Base indentation symbol
Examples:
# Set log level
ezpl config set log_level DEBUG
# Set with environment variable
ezpl config set log_level DEBUG --env
# Set rotation
ezpl config set log_rotation "10 MB"
ezpl config reset¶
Reset configuration to default values.
Options:
--confirm, -y: Skip confirmation prompt
Examples:
# Reset with confirmation
ezpl config reset
# Reset without confirmation
ezpl config reset --confirm
ezpl config export¶
Export configuration as environment variables script.
Options:
--output, -o PATH: Output file path--platform, -p PLATFORM: Platform (unix, windows)
Examples:
# Export for Unix
ezpl config export --output env.sh --platform unix
# Export for Windows
ezpl config export --output env.bat --platform windows
Generated script:
# Unix (env.sh)
export EZPL_LOG_LEVEL="INFO"
export EZPL_LOG_FILE="ezpl.log"
# ...
# Windows (env.bat)
set EZPL_LOG_LEVEL=INFO
set EZPL_LOG_FILE=ezpl.log
Utility Commands¶
ezpl version¶
Display version information.
Options:
--full, -f: Display full version information
Examples:
# Simple version
ezpl version
# Output: 1.5.1
# Full version info
ezpl version --full
# Output:
# Ezpl version 1.5.1
# Python 3.11.0
# Platform: linux
ezpl info¶
Display package information.
Shows detailed information including:
- Package version
- Installation location
- Configuration paths
- Python version
- Core dependencies
Example output:
Ezpl Package Information
========================
Version: 1.5.1
Location: /usr/local/lib/python3.11/site-packages/ezpl
Config Dir: /home/user/.ezpl
Python: 3.11.0
Dependencies:
- loguru: 0.7.2
- rich: 13.7.0
- click: 8.1.7
Environment Variables¶
Ezpl supports the following environment variables:
| Variable | Description | Default |
|---|---|---|
EZPL_LOG_LEVEL |
Global log level | INFO |
EZPL_LOG_FILE |
Log file name | ezpl.log |
EZPL_LOG_DIR |
Log directory | Current directory |
EZPL_PRINTER_LEVEL |
Console level | INFO |
EZPL_FILE_LOGGER_LEVEL |
File level | INFO |
EZPL_LOG_ROTATION |
Rotation setting | None |
EZPL_LOG_RETENTION |
Retention period | None |
EZPL_LOG_COMPRESSION |
Compression format | None |
EZPL_INDENT_STEP |
Indentation step | 3 |
EZPL_INDENT_SYMBOL |
Indent symbol | > |
EZPL_BASE_INDENT_SYMBOL |
Base indent symbol | ~ |
Setting Environment Variables¶
Unix/Linux/macOS:
Windows:
Using CLI:
Best Practices¶
Configuration Management¶
- Use environment variables for environment-specific settings:
- Check configuration before setting:
- Export configuration for team sharing:
Log Management¶
- Use tail --follow for real-time monitoring:
- Export logs before cleaning:
- Use search with level filtering:
- Check statistics regularly:
Automation¶
Example: Daily log backup script (Unix):
#!/bin/bash
DATE=$(date +%Y%m%d)
ezpl logs export --format json --output "backup-$DATE.json"
ezpl logs clean --days 7 --confirm
ezpl logs stats --format json > "stats-$DATE.json"
Example: Log monitoring script:
Configuration File¶
Configuration is stored in ~/.ezpl/config.json:
{
"log_level": "INFO",
"log_file": "ezpl.log",
"printer_level": "INFO",
"file_logger_level": "DEBUG",
"log_rotation": "10 MB",
"log_retention": "7 days",
"log_compression": "zip",
"indent_step": 3,
"indent_symbol": ">",
"base_indent_symbol": "~"
}
See Also¶
- Getting Started - Basic usage guide
- User Guides - Complete guides of project
- API Reference - Complete API documentation
- Examples - Practical examples
Need Help?¶
- Issues: GitHub Issues
- Repository: https://github.com/neuraaak/ezplog