### Initialize Flutter Logs with Custom Settings Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Initializes the Flutter Logs framework with a comprehensive set of custom configurations including log levels, timestamp format, directory structure, enabled log types, file extension, and directory names for writing and exporting. This setup is crucial for tailoring the logging behavior to specific application needs. ```dart await FlutterLogs.initLogs( logLevelsEnabled: [ LogLevel.INFO, LogLevel.WARNING, LogLevel.ERROR, LogLevel.SEVERE ], timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE, directoryStructure: DirectoryStructure.FOR_DATE, logTypesEnabled: [_my_log_file_name], logFileExtension: LogFileExtension.LOG, logsWriteDirectoryName: "MyLogs", logsExportDirectoryName: "MyLogs/Exported", debugFileOperations: true, isDebuggable: true ); ``` -------------------------------- ### Initialize MQTT for Real-Time Logging in Flutter Source: https://context7.com/umair13adil/flutter_logs/llms.txt The `setupMQTTLogging` function initializes MQTT for real-time log streaming to a remote broker over SSL. This allows for live monitoring of application logs on remote dashboards. The `initMQTT` function requires parameters like topic, broker URL, certificate, and client ID. It also includes an option to save logs locally concurrently. ```dart import 'package:flutter_logs/flutter_logs.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); // Initialize standard logging await FlutterLogs.initLogs( logLevelsEnabled: [LogLevel.INFO, LogLevel.ERROR], timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE, directoryStructure: DirectoryStructure.FOR_DATE, logTypesEnabled: [], logFileExtension: LogFileExtension.LOG, logsWriteDirectoryName: "MyLogs", logsExportDirectoryName: "MyLogs/Exported", debugFileOperations: true, isDebuggable: true, enabled: true ); // Setup MQTT for real-time streaming await setupMQTTLogging(); runApp(MyApp()); } Future setupMQTTLogging() async { // Certificate must be added to assets and registered in pubspec.yaml // flutter: // assets: // - assets/m2mqtt_ca.crt await FlutterLogs.initMQTT( topic: "app/logs/production", brokerUrl: "mqtt.example.com", // URL without schema (no mqtt:// or https://) certificate: "assets/m2mqtt_ca.crt", clientId: "flutter_app_001", port: "8883", // SSL port qos: 1, // Quality of Service: 0, 1, or 2 retained: false, writeLogsToLocalStorage: true, // Also save locally debug: true, initialDelaySecondsForPublishing: 30 // Wait before starting MQTT ); FlutterLogs.logInfo("MQTT", "Setup", "MQTT logging initialized"); } class MQTTLogger { // Disable local storage if only MQTT is needed Future setupMQTTOnly() async { await FlutterLogs.initMQTT( topic: "app/logs/production", brokerUrl: "mqtt.example.com", certificate: "assets/m2mqtt_ca.crt", port: "8883", writeLogsToLocalStorage: false, // Skip local file writing debug: true, initialDelaySecondsForPublishing: 10 ); } } ``` -------------------------------- ### Initialize MQTT Logging in Dart Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md This code demonstrates how to initialize MQTT logging with SSL support. It requires a certificate file in the assets directory and specifies the topic, broker URL, certificate name, and port for the MQTT connection. It also shows how to disable writing logs to local storage if only MQTT is needed. ```dart await FlutterLogs.initMQTT( topic: "YOUR_TOPIC", brokerUrl: "", //Add URL without schema certificate: "m2mqtt_ca.crt", port: "8883"); ``` ```dart await FlutterLogs.initMQTT( writeLogsToLocalStorage: false); ``` -------------------------------- ### Initialize and Export Logs with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Initializes the log export directory and then exports all logs. Requires setting up the export path beforehand. ```dart await FlutterLogs.initLogs( logsExportDirectoryName: "MyLogs/Exported"); FlutterLogs.exportLogs( exportType: ExportType.ALL); ``` -------------------------------- ### Initialize Flutter Logs Logging System (Dart) Source: https://context7.com/umair13adil/flutter_logs/llms.txt Configures the Flutter Logs framework with essential parameters such as log levels, directory structure, file formats, and retention policies. This function must be invoked before any logging activities can commence, typically within the application's main function. ```dart import 'package:flutter/material.dart'; import 'package:flutter_logs/flutter_logs.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); // Initialize the logging system with full configuration await FlutterLogs.initLogs( logLevelsEnabled: [ LogLevel.INFO, LogLevel.WARNING, LogLevel.ERROR, LogLevel.SEVERE ], timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE, directoryStructure: DirectoryStructure.FOR_DATE, logTypesEnabled: ["device", "network", "errors", "Locations"], logFileExtension: LogFileExtension.LOG, logsWriteDirectoryName: "MyLogs", logsExportDirectoryName: "MyLogs/Exported", debugFileOperations: true, isDebuggable: true, logsRetentionPeriodInDays: 14, zipsRetentionPeriodInDays: 3, autoDeleteZipOnExport: false, autoClearLogs: true, enabled: true ); runApp(MyApp()); } ``` -------------------------------- ### Log Messages with flutter_logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Demonstrates how to log various types of messages using the flutter_logs framework. It includes methods for logging informational, warning, error, and trace messages with associated tags and sub-tags. These logs are saved to files based on the initialization configuration. ```dart FlutterLogs.logThis( tag: 'MyApp', subTag: 'logData', logMessage: 'This is a log message: ${DateTime.now().millisecondsSinceEpoch}', level: LogLevel.INFO); FlutterLogs.logInfo("TAG", "subTag", "My Log Message"); FlutterLogs.logWarn("TAG", "subTag", "My Log Message"); FlutterLogs.logError("TAG", "subTag", "My Log Message"); FlutterLogs.logErrorTrace("TAG", "subTag", "My Log Message", Error()); ``` -------------------------------- ### Initialize MQTT Logging in Flutter Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Initializes the MQTT feature for logging. It supports SSL connections and allows configuration of the topic, broker URL, certificate, and port. Additionally, it provides an option to disable writing logs to the local storage. ```dart await FlutterLogs.initMQTT( topic: "YOUR_TOPIC", brokerUrl: "", //Add URL without schema certificate: "m2mqtt_ca.crt", port: "8883"); ``` ```dart await FlutterLogs.initMQTT( writeLogsToLocalStorage: false); ``` -------------------------------- ### Manually Export Logs to Zip File Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Manually creates a zip archive of log files from a specified directory. Requires the 'flutter_archive' dependency. ```yaml flutter_archive: ^6.0.3 ``` ```dart Directory? externalDirectory; if (Platform.isIOS) { externalDirectory = await getApplicationDocumentsDirectory(); } else { externalDirectory = await getExternalStorageDirectory(); } File file = File("${externalDirectory!.path}/$_logsDirectory"); final zipFile = File("${externalDirectory.path}/logs.zip"); try { await ZipFile.createFromDirectory( sourceDir: Directory(file.path), zipFile: zipFile, includeBaseDirectory: true); } catch (e) { print(e); } logInfo(_tag, "uploadFile", 'Storage:${file.path}, Zip: ${zipFile.path}'); ``` -------------------------------- ### Configure and Log to Custom Files in Dart Source: https://context7.com/umair13adil/flutter_logs/llms.txt This Dart code demonstrates how to initialize `flutter_logs` with custom log file configurations and then log specific events to these pre-registered files using `logToFile`. This is useful for segregating logs like location data, API calls, or job results. Ensure `WidgetsFlutterBinding.ensureInitialized()` is called before initialization. ```dart import 'package:flutter_logs/flutter_logs.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); // Step 1: Register custom log file names await FlutterLogs.initLogs( logLevelsEnabled: [LogLevel.INFO], timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE, directoryStructure: DirectoryStructure.FOR_DATE, logTypesEnabled: ["Locations", "Jobs", "API"], logFileExtension: LogFileExtension.LOG, logsWriteDirectoryName: "MyLogs", logsExportDirectoryName: "MyLogs/Exported", debugFileOperations: true, isDebuggable: true, enabled: true ); runApp(MyApp()); } class LocationTracker { // Step 2: Log data to specific file Future trackLocation(double lat, double lon) async { await FlutterLogs.logToFile( logFileName: "Locations", overwrite: false, // Append to file logMessage: "{latitude: $lat, longitude: $lon}", appendTimeStamp: true ); } Future logAPICall(String endpoint, int statusCode) async { await FlutterLogs.logToFile( logFileName: "API", overwrite: false, logMessage: "Endpoint: $endpoint, Status: $statusCode", appendTimeStamp: true ); } Future logJobExecution(String jobName, String result) async { await FlutterLogs.logToFile( logFileName: "Jobs", overwrite: false, logMessage: "Job: $jobName, Result: $result", appendTimeStamp: true ); } } ``` -------------------------------- ### Export All Logs as ZIP (Dart) Source: https://context7.com/umair13adil/flutter_logs/llms.txt Compresses and exports all logs to a specified directory. The function returns the path to the generated ZIP file via a method channel callback. It requires the 'flutter_logs' and 'path_provider' packages. ```dart import 'dart:async'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_logs/flutter_logs.dart'; import 'package:path_provider/path_provider.dart'; class LogExporter { final String _tag = "LogExporter"; static Completer _completer = Completer(); void setupExportListener() { // Listen for export completion FlutterLogs.channel.setMethodCallHandler((call) async { if (call.method == 'logsExported') { String zipFileName = call.arguments.toString(); FlutterLogs.logInfo(_tag, "Export", "Logs exported: $zipFileName"); _completer.complete(zipFileName); } }); } Future exportAllLogs() async { _completer = Completer(); // Trigger export of all logs await FlutterLogs.exportLogs( exportType: ExportType.ALL, decryptBeforeExporting: false ); // Wait for export to complete String zipFileName = await _completer.future; // Get file reference Directory? externalDirectory; if (Platform.isIOS) { externalDirectory = await getApplicationDocumentsDirectory(); } else { externalDirectory = await getExternalStorageDirectory(); } File zipFile = File("${externalDirectory!.path}/$zipFileName"); if (zipFile.existsSync()) { FlutterLogs.logInfo(_tag, "Export", "ZIP found at: ${zipFile.path}"); return zipFile; } else { FlutterLogs.logError(_tag, "Export", "ZIP file not found"); return null; } } Future exportLastHourLogs() async { await FlutterLogs.exportLogs( exportType: ExportType.LAST_HOUR, decryptBeforeExporting: false ); } Future exportTodayLogs() async { await FlutterLogs.exportLogs( exportType: ExportType.TODAY, decryptBeforeExporting: false ); } Future exportLast24Hours() async { await FlutterLogs.exportLogs( exportType: ExportType.LAST_24_HOURS, decryptBeforeExporting: false ); } } ``` -------------------------------- ### Initialize flutter_logs Logging Framework Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Initializes the flutter_logs framework with various configuration options. This includes enabling specific log levels and types, setting timestamp formats, directory structures, log file extensions, and retention periods. It also allows for enabling debug operations and auto-clearing logs. ```dart import 'package:flutter_logs/flutter_logs.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); //Initialize Logging await FlutterLogs.initLogs( logLevelsEnabled: [ LogLevel.INFO, LogLevel.WARNING, LogLevel.ERROR, LogLevel.SEVERE ], timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE, directoryStructure: DirectoryStructure.FOR_DATE, logTypesEnabled: ["device","network","errors"], logFileExtension: LogFileExtension.LOG, logsWriteDirectoryName: "MyLogs", logsExportDirectoryName: "MyLogs/Exported", debugFileOperations: true, isDebuggable: true, logsRetentionPeriodInDays = 14, zipsRetentionPeriodInDays = 3, autoDeleteZipOnExport = false, autoClearLogs = true, enabled: true); runApp(MyApp()); } ``` -------------------------------- ### Add Flutter Logs Dependency Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Specifies the 'flutter_logs' package as a dependency in the `pubspec.yaml` file for a Flutter project. Replace `[LATEST_VERSION]` with the actual latest version number available on pub.dev. ```yaml dependencies: flutter_logs: [LATEST_VERSION] ``` -------------------------------- ### Log Exceptions and Errors with Stack Traces in Dart Source: https://context7.com/umair13adil/flutter_logs/llms.txt This Dart code demonstrates how to use the `logThis` and `logErrorTrace` functions from the `flutter_logs` package to log exceptions and errors. It captures detailed stack traces for effective debugging. Ensure the `flutter_logs` package is imported. ```dart import 'package:flutter_logs/flutter_logs.dart'; class ErrorHandler { final String _tag = "ErrorHandler"; Future processData() async { // Log with custom message and level await FlutterLogs.logThis( tag: _tag, subTag: 'processData', logMessage: 'Processing data at ${DateTime.now().millisecondsSinceEpoch}', level: LogLevel.INFO ); // Handle exceptions with full stack trace try { var result = 100 ~/ 0; // Division by zero print("$result"); } catch (e) { if (e is Exception) { await FlutterLogs.logThis( tag: _tag, subTag: 'Division Error', logMessage: 'Caught an exception during calculation', exception: e, level: LogLevel.ERROR ); } } // Handle errors with stack trace try { dynamic nullValue; print(nullValue * 10); } catch (e) { if (e is Error) { await FlutterLogs.logThis( tag: _tag, subTag: 'Null Reference', logMessage: 'Caught an error accessing null value', error: e, level: LogLevel.ERROR ); } } // Log error trace with Error object try { throw StateError("Invalid state"); } catch (e) { if (e is Error) { await FlutterLogs.logErrorTrace( _tag, "State Management", "Application entered invalid state", e ); } } } } ``` -------------------------------- ### Add Certificate to pubspec.yaml Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Specifies assets to be included in the Flutter application, such as a certificate file for MQTT connections. This is a required step before initializing MQTT logging. ```yaml flutter: assets: - m2mqtt_ca.crt ``` -------------------------------- ### Configure ELK Stack Metadata in Flutter Source: https://context7.com/umair13adil/flutter_logs/llms.txt The `configureELKMetadata` function in the `ELKIntegration` class sets up metadata for ELK stack integration. This enables structured logging with rich contextual information, essential for enterprise log analysis. The function takes various parameters to define application and environment details. ```dart import 'package:flutter_logs/flutter_logs.dart'; class ELKIntegration { Future configureELKMetadata() async { await FlutterLogs.setMetaInfo( appId: "com.example.myapp", appName: "My Production App", appVersion: "2.1.5", language: "en-US", deviceId: "device_12345", environmentId: "prod_001", environmentName: "production", organizationId: "org_789", organizationUnitId: "unit_456", userId: "user_98765", userName: "john.doe", userEmail: "john.doe@example.com", deviceSerial: "ABC123XYZ789", deviceBrand: "Samsung", deviceName: "Galaxy S21", deviceManufacturer: "Samsung Electronics", deviceModel: "SM-G991B", deviceSdkInt: "30", deviceBatteryPercent: "85", latitude: "40.7128", longitude: "-74.0060", labels: "premium,beta-tester" ); // After configuration, logs will be JSON-delimited await FlutterLogs.logInfo("ELK", "Setup", "ELK metadata configured"); } } // Expected JSON output format: // { // "user": { // "user.email": "john.doe@example.com", // "user.full_name": "john.doe", // "user.id": "user_98765" // }, // "message": "{ELK} {Setup} ELK metadata configured [timestamp]", // "@version": "1", // "log.logger": "PLogger", // "host": { // "host.type": "Android", // "host.name": "Samsung", // "host.architecture": "Samsung 30" // }, // "app": { // "app.language": "en-US", // "app.id": "com.example.myapp", // "app.name": "My Production App", // "app.version": "2.1.5" // }, // "organization": { // "organization.name": "production", // "organization.id": "org_789" // }, // "geo": { // "geo.location": "{ \"lon\": -74.0060, \"lat\": 40.7128 }" // }, // "@timestamp": "2025-01-15T10:30:00.000Z", // "log.level": "INFO" // } ``` -------------------------------- ### Print Logs with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Prints all logs. This action can be used for displaying log content, potentially for debugging or user feedback. ```dart FlutterLogs.printLogs( exportType: ExportType.ALL); ``` -------------------------------- ### Basic Flutter Logs Logging Operations (Dart) Source: https://context7.com/umair13adil/flutter_logs/llms.txt Provides simple methods to write tagged log entries with different severity levels (info, warn, error). Each entry is automatically timestamped and directed to hourly organized files. This is useful for tracking application flow and handling potential issues. ```dart import 'package:flutter_logs/flutter_logs.dart'; class MyService { final String _tag = "MyService"; Future performOperation() async { // Log informational message await FlutterLogs.logInfo(_tag, "performOperation", "Starting operation at ${DateTime.now()}"); try { // Simulate some work var result = await fetchData(); await FlutterLogs.logInfo(_tag, "performOperation", "Operation completed successfully with result: $result"); } catch (e) { // Log warning for recoverable issues await FlutterLogs.logWarn(_tag, "performOperation", "Retrying operation due to temporary failure"); } } Future handleCriticalOperation() async { try { var data = await riskyOperation(); await FlutterLogs.logInfo(_tag, "handleCriticalOperation", "Critical operation succeeded"); } catch (e) { // Log error for failures await FlutterLogs.logError(_tag, "handleCriticalOperation", "Critical operation failed: ${e.toString()}"); } } Future fetchData() async => "sample_data"; Future riskyOperation() async => throw Exception("Failed"); } ``` -------------------------------- ### Import Flutter Logs Package Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Imports the 'flutter_logs' package into a Dart file, making its classes and functions available for use in the Flutter application. This is a standard import statement required before utilizing the package's features. ```dart import 'package:flutter_logs/flutter_logs.dart'; ``` -------------------------------- ### Listen to Export/Print Results in Dart Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Sets up a method call handler to listen for 'logsExported' and 'logsPrinted' events from the FlutterLogs channel. It checks the existence of exported log files in the device's storage. ```dart import 'dart:async'; import 'dart:io'; import 'package:flutter_logs/flutter_logs.dart'; import 'package:path_provider/path_provider.dart'; FlutterLogs.channel.setMethodCallHandler((call) async { if (call.method == 'logsExported') { var zipName = "${call.arguments.toString()}"; Directory externalDirectory; if (Platform.isIOS) { externalDirectory = await getApplicationDocumentsDirectory(); } else { externalDirectory = await getExternalStorageDirectory(); } FlutterLogs.logInfo(TAG, "found", 'External Storage:$externalDirectory'); File file = File("${externalDirectory.path}/$zipName"); FlutterLogs.logInfo( TAG, "path", 'Path: \n${file.path.toString()}'); if (file.existsSync()) { FlutterLogs.logInfo( TAG, "existsSync", 'Logs found and ready to export!'); } else { FlutterLogs.logError( TAG, "existsSync", "File not found in storage."); } } else if (call.method == 'logsPrinted') { //TODO Get results of logs print here } }); ``` -------------------------------- ### Print Specific File Log with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Prints logs from a specific file identified by its name. This allows for targeted viewing of log content. ```dart FlutterLogs.printFileLogForName( logFileName: "Locations"); ``` -------------------------------- ### Log Exception with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Logs an exception using FlutterLogs.logThis method with the ERROR level. This is suitable for capturing and reporting runtime exceptions. ```dart try { var i = 100 ~/ 0; print("$i"); } catch (e) { FlutterLogs.logThis( tag: 'MyApp', subTag: 'Caught an exception.', logMessage: 'Caught an exception!', exception: e, level: LogLevel.ERROR); } ``` -------------------------------- ### Export Specific File Log with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Exports logs from a specific file identified by its name. Useful for retrieving logs related to a particular feature or module. ```dart FlutterLogs.exportFileLogForName( logFileName: "Locations"); ``` -------------------------------- ### Log Data to File with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Logs messages to a specified file, with options to append or overwrite. This function is essential for persistent logging within the application. ```dart FlutterLogs.logToFile( logFileName: "Locations", overwrite: false, logMessage: "{0.0,0.0}" ); ``` -------------------------------- ### Print Logs to Console (Dart) Source: https://context7.com/umair13adil/flutter_logs/llms.txt Outputs log contents directly to the console for debugging purposes. This function supports various export types and filters without creating ZIP files. A method channel listener can be set up to receive log content. ```dart import 'package:flutter_logs/flutter_logs.dart'; class LogViewer { final String _tag = "LogViewer"; void setupPrintListener() { FlutterLogs.channel.setMethodCallHandler((call) async { if (call.method == 'logsPrinted') { String logContent = call.arguments.toString(); print("Logs printed: $logContent"); } }); } Future printAllLogs() async { // Print all logs to console await FlutterLogs.printLogs( exportType: ExportType.ALL, decryptBeforeExporting: true ); FlutterLogs.logInfo(_tag, "Print", "All logs printed to console"); } Future printTodayLogs() async { await FlutterLogs.printLogs( exportType: ExportType.TODAY, decryptBeforeExporting: false ); } Future printSpecificFileLogs() async { // Print specific custom log file await FlutterLogs.printFileLogForName( logFileName: "Locations", decryptBeforeExporting: false ); FlutterLogs.logInfo(_tag, "Print", "Location logs printed"); } } ``` -------------------------------- ### Log Events Hourly with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Logs a message to an hourly file using the Flutter Logs framework. This function automatically creates a new log file based on the current time, organizing logs for easy retrieval and analysis. It requires a tag, sub-tag, the log message itself, and a log level. ```dart FlutterLogs.logThis( tag: 'MyApp', subTag: 'logData', logMessage: 'This is a log message: ${DateTime.now().millisecondsSinceEpoch}', level: LogLevel.INFO); ``` -------------------------------- ### Configure Custom File Logs in flutter_logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Configures flutter_logs to enable logging into specific custom files defined by log types. This is a prerequisite step before logging data into these custom files, ensuring the logger is aware of the file names to use. ```dart await FlutterLogs.initLogs( logTypesEnabled: ["Locations","Jobs","API"]); ``` -------------------------------- ### Log Data to a Specific Custom File Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Logs data to a predefined custom log file. Developers can specify the `logFileName`, choose to `overwrite` existing content or append to it, and provide the `logMessage`. This is useful for tracking specific event data like location coordinates. ```dart FlutterLogs.logToFile( logFileName: "Locations", overwrite: false, logMessage: "{0.0,0.0}"); ``` -------------------------------- ### Export Custom File Logs (Dart) Source: https://context7.com/umair13adil/flutter_logs/llms.txt Exports specific custom log files or all custom log files as ZIP archives. This allows for selective export of log categories. The 'decryptBeforeExporting' flag can be set to true if the logs are encrypted. ```dart import 'package:flutter_logs/flutter_logs.dart'; class CustomLogExporter { final String _tag = "CustomLogExporter"; Future exportLocationLogs() async { // Export a specific custom log file await FlutterLogs.exportFileLogForName( logFileName: "Locations", decryptBeforeExporting: false ); FlutterLogs.logInfo(_tag, "Export", "Location logs exported"); } Future exportAPILogs() async { await FlutterLogs.exportFileLogForName( logFileName: "API", decryptBeforeExporting: true // Decrypt if logs are encrypted ); FlutterLogs.logInfo(_tag, "Export", "API logs exported"); } Future exportAllCustomLogs() async { // Export all custom file logs at once await FlutterLogs.exportAllFileLogs( decryptBeforeExporting: false ); FlutterLogs.logInfo(_tag, "Export", "All custom logs exported"); } } ``` -------------------------------- ### Export All Logs with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Exports all log files, with an option to decrypt them before exporting. This function is useful for backup or sharing purposes, and allows specifying the export type (e.g., ALL) and whether decryption is needed. ```dart FlutterLogs.exportLogs( exportType: ExportType.ALL, decryptBeforeExporting: true); ``` -------------------------------- ### Log Error with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Logs a runtime error using FlutterLogs.logThis method with the ERROR level. This is used for reporting errors that occur during program execution. ```dart try { var i = null; print(i * 10); } catch (e) { FlutterLogs.logThis( tag: 'MyApp', subTag: 'Caught an error.', logMessage: 'Caught an exception!', error: e, level: LogLevel.ERROR); } ``` -------------------------------- ### Define Custom Log Files with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Enables specific log file types for custom event logging within the Flutter application. This method takes a list of strings, where each string represents a unique log file name (e.g., 'Locations', 'Jobs', 'API'), allowing for categorized data logging. ```dart await FlutterLogs.initLogs( logTypesEnabled: ["Locations","Jobs","API"]); ``` -------------------------------- ### Export Specific Custom File Log Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Exports a specific custom log file based on its name. This function allows for targeted log retrieval and includes an option to decrypt the file before exporting, ensuring secure handling of sensitive log data. ```dart FlutterLogs.exportFileLogForName( logFileName: "Locations", decryptBeforeExporting: true); ``` -------------------------------- ### Configure ELK Elastic Stack Metadata in Flutter Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Sets additional metadata for logs to improve filtering in the LogStash dashboard. Logs will be delimited as JSON. This function takes various parameters related to app information, user details, device information, and location. ```dart await FlutterLogs.setMetaInfo( appId: "flutter_logs_example", appName: "Flutter Logs Demo", appVersion: "1.0", language: "en-US", deviceId: "00012", environmentId: "7865", environmentName: "dev", organizationId: "5767", userId: "883023-2832-2323", userName: "umair13adil", userEmail: "m.umair.adil@gmail.com", deviceSerial: "YJBKKSNKDNK676", deviceBrand: "LG", deviceName: "LG-Y08", deviceManufacturer: "LG", deviceModel: "989892BBN", deviceSdkInt: "26", latitude: "0.0", longitude: "0.0", labels: "", ); ``` -------------------------------- ### Clear All Logs with Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/README.md Clears all log files managed by the flutter_logs package. This is useful for resetting log data. ```dart FlutterLogs.clearLogs(); ``` -------------------------------- ### Clear All Logs in Flutter Source: https://context7.com/umair13adil/flutter_logs/llms.txt The `clearAllLogs` function within the `LogManager` class deletes all log files from the storage directory. It's useful for freeing up space or resetting the logging system. The `performMaintenanceCleanup` function also utilizes `FlutterLogs.clearLogs()` for maintenance operations. ```dart import 'package:flutter_logs/flutter_logs.dart'; class LogManager { final String _tag = "LogManager"; Future clearAllLogs() async { await FlutterLogs.clearLogs(); FlutterLogs.logInfo(_tag, "Clear", "All logs have been cleared"); } Future performMaintenanceCleanup() async { // Clear logs before app update or during maintenance await FlutterLogs.clearLogs(); FlutterLogs.logInfo(_tag, "Maintenance", "Maintenance cleanup completed at ${DateTime.now()}"); } } ``` -------------------------------- ### Clear All Logs in Flutter Logs Source: https://github.com/umair13adil/flutter_logs/blob/master/example/README.md Clears all log files that have been generated by the Flutter Logs framework. This is a utility function for managing storage space and ensuring that only relevant logs are retained. ```dart FlutterLogs.clearLogs(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.