pd_log 1.0.0
pd_log: ^1.0.0 copied to clipboard
Cross-platform Flutter logging with pure Dart; buffered file writes; no platform channels.
pd_log #
δΈζ | English
Lightweight, cross-platform Flutter logging plugin with unified Dart file buffering and platform event listening.
Features #
- Multi-level logging: Verbose, debug, info, warn, error levels with ANSI styling
- Dart file buffering: Cross-platform unified write thread buffering with timed/threshold flush
- File query & maintenance: List/delete logs, rotation cleanup, organize by year/month/day
- Metadata tracking: Event ledger (NDJSON) and snapshot (JSON) auto-maintenance
- Cross-platform unified: Web console output (no file writes), consistent API
- Log file export: Export logs to system directories or custom paths
- Sensitive data masking: Independent mask processor with configurable strategies and rules
- Log content search: Full-text keyword matching with context lines and time range filtering
- Embedded log viewer: Overlay-based floating button with inline log viewing page
- Theming system: Unified UI colors and ANSI styles management with preset themes
- Structured logging: ECS (Elastic Common Schema) format support for ELK integration
- Network request interception: Optional logging for Dio and http packages
Platform Support #
| Platform | Support | Notes |
|---|---|---|
| Android | Yes | File logging, console output, file events (polling) |
| iOS | Yes | File logging, console output, file events (polling) |
| macOS | Yes | File logging, console output, file events (watcher) |
| Windows | Yes | File logging, console output, file events (watcher) |
| Linux | Yes | File logging, console output, file events (watcher) |
| Web | Limited | Console output only, no file system access |
Quick Start #
Add the dependency to your pubspec.yaml and configure the logger with console and file configurations. Detailed usage instructions are available in the Getting Started guide.
Documentation #
Configuration #
pd_log uses a split configuration architecture with separate modules for console and file logging:
- ConsoleConfig: Controls console output behavior including enabled status, minimum log level, timestamp display, caller information, and theme selection
- FileConfig: Controls file writing behavior including enabled status, minimum log level, output format (Simple JSON or ECS), buffer flush settings, retention strategy, and masking configuration
See Configuration for detailed parameter descriptions and usage examples.
Log Format #
Two output formats are supported:
- Simple JSON: Default format with basic log fields
- ECS (Elastic Common Schema): Structured format for seamless ELK stack integration with standard fields like
@timestamp,log.level,log.logger,message, andlog.origin
See Styling & Formatting for format examples and configuration details.
Theming #
pd_log provides preset themes (light, dark, noColor) and custom theme support for console output styling. See Theming System for theme configuration options.
Embedded Log Viewer #
An overlay-based floating button provides quick access to an inline log viewing page with filtering, search, sorting, real-time monitoring, and export capabilities. See Log Viewer for usage instructions.
Network Request Interception #
Optional network logging for Dio and http packages with automatic request/response logging, sensitive data masking, slow request detection, and request duration tracking. See Network Logging for detailed integration guide.
Additional Documentation #
- File Storage & Rotation - File writing, buffering, and rotation strategies
- Query & Pagination - Log file listing, sorting, and pagination
- Metadata & History - Event ledger and snapshot management
- Log Masking - Sensitive data protection with configurable rules
- Log Search - Full-text search across log files
- Log Export - Export logs to system directories
- Web Platform - Web-specific behavior and limitations
- Buffer Flush & Event Listening - File event monitoring and buffer management
Example Project #
A comprehensive example application is available in the example/ directory, demonstrating all features including network request logging with Dio integration. Run with flutter run.
License #
MIT (see root LICENSE).