flutter_log_handler 0.1.0
flutter_log_handler: ^0.1.0 copied to clipboard
Enterprise-grade Flutter logging with console/file logs, crash capture, API interception, and built-in log viewer UI.
flutter_log_handler #
Enterprise-Grade Logging, Crash Tracking & API Monitoring Framework for Flutter
A production-ready logging infrastructure built specifically for modern Flutter applications.
Designed for enterprise apps, production builds, QA testing, white-label solutions, and scalable client deployments.
π Why Use flutter_log_handler? #
print() is not production logging.
Modern Flutter apps require:
- β Structured logs (info / warning / error)
- β Persistent local storage with retention policy
- β Crash capture & reporting
- β API request/response tracking with performance monitoring
- β Sensitive data masking (passwords, tokens, API keys)
- β Enterprise-grade log viewer (search, filter, export)
- β Shareable diagnostics for QA and supportExportable logs (TXT / JSON / PDF)
flutter_log_handler delivers a complete observability layer inside your Flutter application.
Lightweight. Configurable. Enterprise-ready.
π― Ideal Use Cases #
- Enterprise Flutter apps
- Production & QA builds
- API performance tracking & crash diagnostics
- White-label client deployments
- Large-scale apps requiring structured logs
π₯ Core Features #
| Feature | Description | Badge |
|---|---|---|
| Structured Logging | Log levels, timestamps, stack trace, route & API tracking, custom tags | π |
| Crash Capture | Flutter errors, unhandled exceptions, async & zone errors, device metadata | π₯ |
| Hive Persistence | Local log storage with retention days & auto-cleanup | π |
| API Monitoring | Dio interceptor, slow API detection, masked request/response logging | π |
| Sensitive Data Masking | Auto-mask keys like password, token, apiKey | π |
| Log Viewer UI | Animated filter chips, real-time search, expandable stack traces, Pull-to-refresh, Pull-to-refresh, Copy log button, Share logs, Clean production-ready card UI |
π₯ |
| Export Logs | TXT / JSON / PDF, only today logs, grouped by date, customizable formats | π€ |
| Session & Env Tags | Automatic session ID & environment (flavor, version, platform) tagging | π‘ |
π¦ Installation #
dependencies:
flutter_log_handler: ^0.1.0
Then run:
flutter pub get
βοΈ Quick Setup #
Initialize Logger in main() #
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Start session
SessionManager.startSession();
// Set environment tags
LogContext.setEnvironment(
flavor: "development",
appVersion: "0.0.6",
platform: "android",
);
// Initialize Hive log service
await LogServiceHive.init(
LogConfig(
retentionDays: 5,
enableConsoleLog: true,
sensitiveKeys: ["password", "token", "apiKey"],
),
);
runApp(const MyApp());
}
π Logging Examples #
Simple Log #
LogServiceHive.to.logEvent(
message: "User logged in",
level: LogLevel.info,
);
Log with Stack Trace #
LogServiceHive.to.logEvent(
message: error.toString(),
stackTrace: stack.toString(),
level: LogLevelHive.error,
);
Log with API Endpoint #
LogServiceHive.to.logEvent(
message: "API Failed",
level: LogLevel.error,
stackTrace: stack.toString(),
apiEndpoint: "/api/login",
);
Fetch Logs #
// Fetch all logs stored in Hive (latest first)
final logs = await LogServiceHive.to.getLogs();
// Example:
for (var log in logs) {
print("[${log.level.name.toUpperCase()}] ${log.timestamp}: ${log.message}");
}
π₯ Crash Capture Setup #
await CrashWrapper.initialize(
logService: LogServiceHive.to,
);
Automatically captures:
- Flutter framework errors
- Unhandled async errors & Zone errors
- Device, platform, Session ID and environment tags
π API Monitoring with Dio #
final dio = Dio();
dio.interceptors.add(
ApiInterceptor(LogServiceHive.to),
);
Logs:
- Request method & endpoint
- Request/response bodies (masked)
- Status & duration
- Slow API warnings
- API errors with stack traces
π₯ Open Log Viewer Screen #
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => LogViewerScreen(
title: "App Logs",
// Action buttons
enableShareButton: true,
enableRefreshButton: true,
enableClearButton: true,
// Search & filter
enableCollapsibleSearch: true,
showLevelChips: true,
enablePullToRefresh: true,
// Export system
enableCustomExportMenu: true,
allowedExportFormats: [
LogExportFormat.txt,
LogExportFormat.json,
LogExportFormat.pdf,
],
exportGroupByDate: true,
exportFormat: LogExportFormat.pdf,
),
),
);
#Features:
- Filter by log level
- Expand stack traces
- Refresh logs
- Share logs
- Enterprise UI design
π Configuration Options #
LogConfig(
retentionDays: 5,
enableConsoleLog: true,
sensitiveKeys: ["password", "secretKey"],
);
| Parameter | Description |
|---|---|
| retentionDays | Auto-delete logs older than X days |
| enableConsoleLog | Print logs in debug console |
| sensitiveKeys | Keys automatically masked to protect sensitive data |
π Log Storage Location #
- Hive stores logs in your app's internal storage:
ApplicationDocumentsDirectory / hive / app_logs
π‘ Architecture Highlights #
- Automatic route tracking
- Automatic crash tagging
- Session & environment tagging (SessionManager + LogContext)
- Enterprise filtering engine
- No dependency injection required
- Works with GetX or without it
- Easily extendable to cloud upload
- Modular production-ready architecture
- Safe for release builds
π SEO Keywords #
Flutter logger
Flutter crash logger
Flutter file logger
Flutter API interceptor
Flutter production monitoring
Flutter enterprise logging
Flutter monitoring framework
Flutter error tracking
Flutter debugging tool
Flutter performance monitoring
π Designed for Production #
flutter_log_handler flutter_log_handler provides structured, production-safe logging for enterprise-grade Flutter apps.
π License #
MIT License
π¨βπ» Maintainer #
ASTR Raju
Enterprise Flutter Developer
GitHub: https://github.com/ASTR001