flutter_log_handler 0.0.2
flutter_log_handler: ^0.0.2 copied to clipboard
Enterprise-grade logging solution for Flutter applications. Provides console logging, file persistence, crash capturing, Dio API interception, retention control, and a built-in professional log viewer UI.
flutter_log_handler #
Enterprise-Grade Logging & Monitoring Framework for Flutter
A production-ready logging solution built specifically for Flutter applications.
Designed for scalable apps, internal admin panels, QA builds, and production monitoring.
π₯ Why flutter_log_handler? #
Modern Flutter applications need more than print().
They need:
- Structured logs
- Persistent storage
- Crash tracking
- API monitoring
- Performance visibility
- Internal log viewer
- Controlled retention
- Shareable diagnostics
flutter_log_handler provides all of that in a lightweight, configurable, and extensible architecture.
π Core Capabilities #
π Structured Logging #
Clean log model with levels, timestamps, routes and stack traces.
π File Persistence #
Logs saved locally with configurable directory & file name.
π§ In-Memory Log Store #
Fast access without reading file every time.
π Professional Log Viewer UI #
Built-in log screen with:
- Filtering by level
- Expandable stack traces
- Refresh support
- Share logs
- Clean enterprise UI
π₯ Automatic Crash Capture #
Capture:
- Flutter framework errors
- Unhandled runtime exceptions
- Zoned errors
π Dio API Interceptor #
Automatic logging of:
- Requests
- Responses
- Slow APIs
- API errors
- Duration tracking
π§Ή Retention & Log Limit Control #
- Maximum log count
- Retention days support
- File rotation ready architecture
π― Ideal For #
- Enterprise Flutter apps
- Production builds
- QA debugging
- Internal monitoring dashboards
- Crash diagnostics
- API performance tracking
- White-label client apps
π¦ Installation #
dependencies:
flutter_log_handler: ^0.0.2
flutter pub get
βοΈ Quick Setup #
1οΈβ£ Initialize Logger #
void main() async {
WidgetsFlutterBinding.ensureInitialized();
LogService.init(
const LogConfig(
maxLogs: 1000,
retentionDays: 7,
enableConsoleLog: true,
enableFileLog: true,
fileName: "app_logs.txt",
directoryName: "logs",
),
);
await LogService.to.getLogs();
runApp(const MyApp());
}
## π Sensitive Data Masking
flutter_log_handler automatically masks sensitive fields such as:
- password
- token
- accessToken
- refreshToken
- authorization
- apiKey
You can customize this:
LogConfig(
sensitiveKeys: ["password", "secretKey"],
);
π Log Events Anywhere #
LogService.to.logEvent(
message: "User logged in",
level: LogLevel.info,
);
π₯ Load Logs Automatically #
await LogService.to.getLogs();
This will:
- Load logs from file (if enabled)
- Sync logs into memory
- Prepare logs for UI display
With Stack Trace #
LogService.to.logEvent(
message: error.toString(),
level: LogLevel.error,
stackTrace: stack.toString(),
);
π§Ή Crash Capture Setup #
await CrashWrapper.initialize(
app: const MyApp(),
logService: LogService.to,
);
Automatically captures:
- Flutter framework errors
- Unhandled async errors
- Zone errors
π API Monitoring (Dio) #
final dio = Dio();
dio.interceptors.add(
ApiInterceptor(LogService.to),
);
Logs:
- HTTP method
- URL
- Response status
- API duration
- Slow APIs (>2000ms)
- Error stack traces
π₯ Professional Log Viewer #
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const MyLogScreen(),
),
);
Features:
- Filter logs by level
- Expand stack traces
- Refresh logs
- Share logs
- Clean enterprise card layout
π Configuration Options #
LogConfig(
maxLogs: 500,
retentionDays: 5,
enableConsoleLog: true,
enableFileLog: true,
fileName: "app_logs.txt",
directoryName: "logs",
);
| Parameter | Description |
|---|---|
| maxLogs | Maximum logs stored in memory |
| retentionDays | Auto-delete logs older than X days |
| enableConsoleLog | Print logs in debug console |
| enableFileLog | Persist logs to file |
| fileName | Log file name |
| directoryName | Folder inside app documents |
π Storage Location #
ApplicationDocumentsDirectory / directoryName / fileName
Example:
/data/user/0/com.example.app/documents/logs/app_logs.txt
π‘ Architecture Highlights #
- Singleton-based LogService
- Configurable behavior
- Zero dependency injection requirement
- Works with GetX or without it
- Extendable for cloud upload
- Future-ready for log rotation
π SEO Keywords #
Flutter logger
Flutter crash logger
Flutter file logger
Flutter monitoring tool
Flutter API interceptor
Flutter production logging
Flutter enterprise logging
π Designed for Production #
flutter_log_handler is built for teams that require reliability, observability, and structured monitoring inside Flutter applications.
π License #
MIT License
π¨βπ» Maintainer #
ASTR Raju
Enterprise Flutter Developer