omni_logger 2.0.0
omni_logger: ^2.0.0 copied to clipboard
Omni Logger is a production-ready logging package for Flutter with auto-configuration, file rotation, isolate support, and build mode optimization.
đ Omni Logger #
Production-ready logging for Flutter with auto-configuration and file management.
Built on the trusted logger package with production-ready enhancements and intelligent auto-configuration.
⥠Quick Start #
1. Add Dependency #
dependencies:
omni_logger: ^2.0.0
2. Setup & Use #
import 'package:omni_logger/omni_logger.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
try {
await AppLog.setup();
} catch (e) {
debugPrint('AppLog setup failed: $e');
}
runApp(const MyApp());
}
// Use anywhere in your app
AppLog.log('Auth').i('User login successful');
AppLog.log('Payment').e('Payment failed');
AppLog.log('Database').d('Query executed');
Table of Contents #
⨠Features #
| Feature | Detail |
|---|---|
| Zero-config setup | AppLog.setup() â auto-detects debug/profile/release |
| File management | Auto rotation, compression, and cleanup |
| Build optimization | Different log levels and retention per build mode |
| Persistent logs | Survives app restarts for production debugging |
| Isolate-aware | Specialized setup for database and background isolates |
| Cross-platform paths | path_provider for reliable, persistent storage on all platforms |
| Safe fallbacks | Three-layer fallback ensures logging never crashes your app |
đ§ Smart Auto-Configuration #
Omni Logger automatically optimizes based on your Flutter build mode:
| Build Mode | Log Level | Files | Size Each | Retention | Console |
|---|---|---|---|---|---|
| Debug | DEBUG | 3 files | 5MB | 3 days | â |
| Profile | WARNING | 2 files | 3MB | 2 days | â |
| Release | ERROR | 1 file | 1MB | 1 day | â |
đ Logging Levels #
AppLog.log('ClassName').t('Trace message'); // đ Trace
AppLog.log('ClassName').d('Debug message'); // đ Debug
AppLog.log('ClassName').i('Info message'); // âšī¸ Info
AppLog.log('ClassName').w('Warning message'); // â ī¸ Warning
AppLog.log('ClassName').e('Error message'); // â Error
AppLog.log('ClassName').f('Fatal message'); // đ Fatal
đ Isolate Support #
// Database isolate (Drift, etc.)
try {
await AppLog.setupForDatabaseIsolate(isolateName: 'drift_db');
} catch (e) {
debugPrint('AppLog database isolate setup failed: $e');
}
AppLog.log('Database').d('Query executed successfully');
// Background isolate
try {
await AppLog.setupForBackgroundIsolate(isolateName: 'sync_worker');
} catch (e) {
debugPrint('AppLog background isolate setup failed: $e');
}
AppLog.log('SyncService').w('Sync took longer than expected');
đą Platform Support #
| Platform | Console | File Logging |
|---|---|---|
| Android | â | â |
| iOS | â | â |
| macOS | â | â |
| Windows | â | â |
| Linux | â | â |
| Web | â | â (by design) |
Contributing #
Contributions are welcome! Please submit pull requests to our repository.
License #
MIT License â see LICENSE for details.
Platform Support: â Android, iOS, macOS, Windows, Linux | đ Web (console only)
Built with â¤ī¸ for the Flutter community