Giter VIP home page Giter VIP logo

umair13adil / flutter_logs Goto Github PK

View Code? Open in Web Editor NEW
39.0 2.0 28.0 2.31 MB

An extensive logging framework developed for flutter apps.

Home Page: https://itnext.io/sending-logs-from-flutter-apps-in-real-time-using-elk-stack-mqtt-c24fa0cb9802

License: Apache License 2.0

Kotlin 42.15% Ruby 3.01% Swift 24.41% Objective-C 0.90% Dart 29.53%
logs logstash elk-stack kibana flutter flutter-plugin logging-library logger filelogger mqtt mqtt-client dart logging

flutter_logs's Introduction

flutter_logs

A file based advanced logging framework for Flutter Apps (Android & iOS).

pub package

Overview

Flutter Logs provides quick & simple file based logging solution. All logs are saved to files in storage path provided. A new log file is created every hour on a new log event. These logs can be filtered and sorted easily. Logs can easily be exported as zip file base on filter type. PLogs also provide functionality to arrange data logs into a predefined directory structure. Custom logs can be used for a specific events based logging within the app. Logs can be saved as encrypted for security purposes.

Flutter logs can work with Logstash by writing JSON delimited logs to log files. The format is based on ELK schema. You can also send logs in real-time to server using MQTT. MQTT configuration can be applied on Logstash to receive & view logs on kibana dashboard.

Image1

Read more about flutter_logs usage on this Medium article:

Sending logs from Flutter apps in real-time using ELK stack & MQTT

Features (Android)

  • Logs events in files created separately every hour (24 hours event based)
  • Files can be compressed and exported for time and day filters
  • Clear Logs easily
  • Save & Export Logs to app's directory as zip file
  • Custom Log formatting options
  • CSV support
  • Custom timestamps support
  • Custom file data logging support.
  • Encryption support added
  • Multiple directory structures
  • Print logs as String
  • Export all or single types of logs
  • ELK Stack Supported See more about it here.
  • MQTT Support (SSL)

Features (iOS)

Note: Work is in progress. More features will be added soon.
  • Logs events in files
  • Files can be compressed and exported
  • Clear Logs easily
  • Save & Export Logs to app's directory as zip file
  • Print logs as String

Install

In your pubspec.yaml

dependencies:
    flutter_logs: [Latest_Version]
import 'package:flutter_logs/flutter_logs.dart';

Setting Up

Initialization


In your main.dart file add like this:

   
   import 'package:flutter_logs/flutter_logs.dart';

   Future<void> 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
     );

     runApp(MyApp());
   }

How to log data?

You have 2 choices for logging:

Hourly Logs

Hourly logs are automatically generated once this line is called. These logs are sorted and named according to current time (24h format) on device e.g. 0110202013.log

FlutterLogs.logThis(
        tag: 'MyApp',
        subTag: 'logData',
        logMessage:
            'This is a log message: ${DateTime.now().millisecondsSinceEpoch}',
        level: LogLevel.INFO);

Or simply call this:

    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());

This will create a new file in storage directory according to time on device. For a single date, all logs will be present in a single directory.

Custom File Logs

If you want to log data into a specific file for some events, you can do this in 2 steps:

These logs will be kept in a seperate file.

Step 1:

[IMPORTANT] Define log file name in logs configuration, logger needs the name to find the file on storage, otherwise no data will be logged.

Here 3 files of logs are defined, logger will use these file name as keys to write data in them.

    await FlutterLogs.initLogs(
        logTypesEnabled: ["Locations","Jobs","API"]);

Step 2:

Log data to file. You can choose to either append to file or overwrite to complete file.

    FlutterLogs.logToFile(
        logFileName: "Locations",
        overwrite: false,
        logMessage:
            "{0.0,0.0}");

Where are my logs stored?

Your logs can be found in the path of your app's directory in storage:

Android:

--> Android/data/[YOUR_APP_PACKAGE]/files/[YOUR_LOGS_FOLDER_NAME]/Logs/

Image2

iOS:

--> [YOUR_APP_CONTAINER]/AppData/Library/Application Support/Logs/

Image3

Export/Print Logs

You can export logs to output path sepcified in logs configuration:

    await FlutterLogs.initLogs(
        logsExportDirectoryName: "MyLogs/Exported");

To export logs call this:

    FlutterLogs.exportLogs(
        exportType: ExportType.ALL);
    FlutterLogs.printLogs(
        exportType: ExportType.ALL);

To export custom file logs:

 FlutterLogs.exportFileLogForName(
        logFileName: "Locations");
 FlutterLogs.printFileLogForName(
        logFileName: "Locations");

Listen to export/print results:


    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
        }
      });

Clear Logs

 FlutterLogs.clearLogs();

Errors/Exception Logs

Printing exception logs:

      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);
      }

Printing error logs:

      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);
      }

ELK Elastic Stack Schema Support


Send additional Meta info for better filtering at LogStash dashboard. With this setting, logs will be logged as JSON-delemited.

    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: "[email protected]",
      deviceSerial: "YJBKKSNKDNK676",
      deviceBrand: "LG",
      deviceName: "LG-Y08",
      deviceManufacturer: "LG",
      deviceModel: "989892BBN",
      deviceSdkInt: "26",
      latitude: "0.0",
      longitude: "0.0",
      labels: "",
    );

Output of logs will be like this:

{
  "user": {
    "user.email": "[email protected]",
    "user.full_name": "umair",
    "user.id": "17282738",
    "user.hash": "1",
    "user.name": "Umair"
  },
  "message": "{OkHttpClient}  {X-XSS-Protection: 1; mode=block} [30 June 2020 04:15:16 PM]",
  "@version": "1",
  "log.logger": "PLogger",
  "host": {
    "host.type": "Android",
    "host.name": "LG",
    "host.architecture": "LG 23",
    "host.hostname": "8000",
    "host.id": "LG",
    "host.ip": "0.0.0.0",
    "host.mac": ""
  },
  "labels": "{}",
  "app": {
    "app.language": "en-US",
    "app.id": "com.example.develop",
    "app.name": "Flutter Dev",
    "app.version": "0.0.108"
  },
  "process.thread.name": "DATA_LOG",
  "organization": {
    "organization.name": "debug",
    "organization.id": "BlackBox"
  },
  "geo": {
    "geo.location": "{ \"lon\": 0.0, \"lat\": 0.0 }"
  },
  "service.name": "Network",
  "@timestamp": "2020-06-30T16:27:36.894Z",
  "topic": "com.flutter.elk.logs",
  "log.level": "INFO"
}

Enable MQTT Feature


Note: PLogger currently supports SSL connection for MQTT.

Step 1:

Add certificate in your assets directory.

Step 2:

Add following line in your pubspec file.

flutter:
  assets:
     - m2mqtt_ca.crt
Step 3:

Add following block for initializing MQTT logging.

    await FlutterLogs.initMQTT(
        topic: "YOUR_TOPIC",
        brokerUrl: "", //Add URL without schema
        certificate: "m2mqtt_ca.crt",
        port: "8883");

That's it, MQTT setup is done. If only MQTT feature is required then set this flag to false to stop writing logs to storage directory:

    await FlutterLogs.initMQTT(
        writeLogsToLocalStorage: false);

Native Libraries

For more details about RxLogs visit this Wiki

Author

Flutter Logs plugin is developed by Umair Adil. You can email me at [email protected] for any queries.

Support

Buy a coffe to Umair Adil, creator of this plugin.

Buy me a coffee

flutter_logs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter_logs's Issues

Build execution fails

I'm getting the following error when trying to build the debug version:

Execution failed for task ':app:mergeDebugAssets'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve com.github.umair13adil:RxLogs:1.0.15.
Required by:
project :app > project :flutter_logs
> Could not resolve com.github.umair13adil:RxLogs:1.0.15.
> Could not get resource 'https://jitpack.io/com/github/umair13adil/RxLogs/1.0.15/RxLogs-1.0.15.pom'.
> Could not GET 'https://jitpack.io/com/github/umair13adil/RxLogs/1.0.15/RxLogs-1.0.15.pom'. Received status code 407 from server: Proxy Authentication Required

Trying to export all log files on Android fails with ENAMETOOLONG

How I initialize:

    FlutterLogs.setDebugLevel(0);
    final List<LogLevel> logLevels = logLevelThreshold == logLevelNone ? [] : [LogLevel.INFO, LogLevel.WARNING, LogLevel.ERROR, LogLevel.SEVERE];
    await FlutterLogs.initLogs(
      logLevelsEnabled: logLevels,
      timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE,
      directoryStructure: DirectoryStructure.FOR_DATE,
      logTypesEnabled: ["device", "network", "errors"],
      logFileExtension: LogFileExtension.TXT,
      logsWriteDirectoryName: "Logs",
      logsExportDirectoryName: "Logs/Exported",
      debugFileOperations: kDebugMode,
      isDebuggable: kDebugMode,
    );

Then when I FlutterLogs.exportLogs(exportType: ExportType.ALL); I get:

W/System.err(23985): java.io.FileNotFoundException: /storage/emulated/0/Android/data/dev.csaba.track_my_indoor_exercise/files/Logs/Logs/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Export
W/System.err(23985): at libcore.io.IoBridge.open(IoBridge.java:492)
W/System.err(23985): at java.io.FileOutputStream.(FileOutputStream.java:236)
W/System.err(23985): at java.io.FileOutputStream.(FileOutputStream.java:186)
W/System.err(23985): at kotlin.io.FilesKt__UtilsKt.copyTo(Utils.kt:236)
W/System.err(23985): at kotlin.io.FilesKt__UtilsKt.copyTo$default(Utils.kt:217)
W/System.err(23985): at kotlin.io.FilesKt__UtilsKt.copyRecursively(Utils.kt:328)
W/System.err(23985): at kotlin.io.FilesKt__UtilsKt.copyRecursively$default(Utils.kt:288)
W/System.err(23985): at com.blackbox.plog.pLogs.filter.FileFilter.getFilesForAll(Unknown Source:40)
W/System.err(23985): at com.blackbox.plog.pLogs.exporter.ExportTypesKt.getLogsForAllInRoot(Unknown Source:10)
W/System.err(23985): at com.blackbox.plog.pLogs.exporter.ExportTypesKt.getFilesForRequestedType(Unknown Source:85)
W/System.err(23985): at com.blackbox.plog.pLogs.exporter.LogExporter$getZippedLogs$1.subscribe(Unknown Source:26)
W/System.err(23985): at io.reactivex.internal.operators.observable.ObservableCreate.subscribeActual(ObservableCreate.java:40)
W/System.err(23985): at io.reactivex.Observable.subscribe(Observable.java:12267)
W/System.err(23985): at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
W/System.err(23985): at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
W/System.err(23985): at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
W/System.err(23985): at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
W/System.err(23985): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err(23985): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
W/System.err(23985): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(23985): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(23985): at java.lang.Thread.run(Thread.java:923)
W/System.err(23985): Caused by: android.system.ErrnoException: open failed: ENAMETOOLONG (File name too long)
W/System.err(23985): at libcore.io.Linux.open(Native Method)
W/System.err(23985): at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
W/System.err(23985): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:254)
W/System.err(23985): at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
W/System.err(23985): at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7885)
W/System.err(23985): at libcore.io.IoBridge.open(IoBridge.java:478)
W/System.err(23985): ... 21 more
E/PLogger (23985): {FlutterLogsPlugin} {exportPLogs} {PLog Error: /storage/emulated/0/Android/data/dev.csaba.track_my_indoor_exercise/files/Logs/Logs/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/Exported/Temp/E
E/PLogger (23985):

compiling for iOS 9.0, but module 'ZIPFoundation' has a minimum deployment target of iOS 12.0

compiling for iOS 9.0, but module 'ZIPFoundation' has a minimum deployment target of iOS 12.0: /Users/macsystem/Library/Developer/Xcode/DerivedData/Runner-dbdcnkggaxlqmdboaajglvasxgse/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/ZIPFoundation/ZIPFoundation.framework/Modules/ZIPFoundation.swiftmodule/arm64-apple-ios.swiftmodule

Could not resolve all artifacts for configuration ':flutter_logs:classpath'.

Hi,
I can not seem to build Version 2.1.7

Flutter 3.3.6

kotlin_version = '1.5.31'

 dependencies {
        classpath 'com.android.tools.build:gradle:7.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }

distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

Log excerpt (github action):

Running Gradle task 'assembleDebug'...                          
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':flutter_logs'.
> Could not resolve all artifacts for configuration ':flutter_logs:classpath'.
   > Could not resolve com.android.tools.analytics-library:crash:27.1.3.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3
      > Could not resolve com.android.tools.analytics-library:crash:27.1.3.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/analytics-library/crash/27.1.3/crash-27.1.3.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/analytics-library/crash/27.1.3/crash-27.1.3.pom'.
               > Read timed out
   > Could not resolve com.android.tools.build:bundletool:0.14.0.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3
      > Could not resolve com.android.tools.build:bundletool:0.14.0.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/bundletool/0.14.0/bundletool-0.14.0.pom'.
            > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/bundletool/0.14.0/bundletool-0.14.0.pom'.
               > Read timed out
   > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-util-klib:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-tooling-metadata:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-project-model:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-android-extensions:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-compiler-runner:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.5.20.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
      > Skipped due to earlier error
   > Could not resolve org.ow2.asm:asm-tree:7.0.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.build:builder:4.1.3
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > org.ow2.asm:asm-analysis:7.0
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > org.ow2.asm:asm-commons:7.0
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > org.ow2.asm:asm-util:7.0
      > Skipped due to earlier error
   > Could not resolve it.unimi.dsi:fastutil:7.2.0.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.build:builder:4.1.3
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-reflect:1.3.72.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.lint:lint-gradle-api:27.1.3
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.build:builder:4.1.3 > com.android.tools:sdk-common:27.1.3
      > Skipped due to earlier error
   > Could not resolve org.glassfish.jaxb:jaxb-runtime:2.3.1.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > androidx.databinding:databinding-compiler-common:4.1.3
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.build:builder:4.1.3 > com.android.tools:sdklib:27.1.3 > com.android.tools:repository:27.1.3
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.3.72.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72
      > Skipped due to earlier error
   > Could not resolve net.sf.proguard:proguard-base:6.0.3.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > net.sf.proguard:proguard-gradle:6.0.3
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.3.72.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.build.jetifier:jetifier-core:1.0.0-beta09
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta09
      > Skipped due to earlier error
   > Could not resolve org.checkerframework:checker-qual:2.11.1.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > org.tensorflow:tensorflow-lite-metadata:0.1.0-rc1
      > Skipped due to earlier error
   > Could not resolve org.checkerframework:checker-qual:2.11.1.
     Required by:
         project :flutter_logs > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20 > com.google.guava:guava:29.0-jre
      > Skipped due to earlier error
   > Could not resolve org.apache.commons:commons-compress:1.12.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.build:builder:4.1.3 > com.android.tools:sdklib:27.1.3
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.build:builder:4.1.3 > com.android.tools:sdklib:27.1.3 > com.android.tools:repository:27.1.3
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.trove4j:trove4j:20160824.
     Required by:
         project :flutter_logs > com.android.tools.build:gradle:4.1.3 > com.android.tools.build:builder:4.1.3 > com.android.tools:sdk-common:27.1.3
      > Skipped due to earlier error
> Failed to notify project evaluation listener.
   > Could not get unknown property 'android' for project ':flutter_logs' of type org.gradle.api.Project.
   > Could not get unknown property 'android' for project ':flutter_logs' of type org.gradle.api.Project.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org/
BUILD FAILED in 4m 30s

FlutterLogs.exportLogs doesn't return (await hangs) if there are 0 files

My code is FlutterLogs.exportLogs(exportType: ExportType.ALL); as a preparation for exporting all logs. My app has a button the user can tap to export logs. However if there wasn't any logging going on so far (0 files) then the function call doesn't return. I see this in the debug log output:

I/ExportTypes(17208): getLogsForAllInRoot: Path: /storage/emulated/0/Android/data/dev.csaba.track_my_indoor_exercise/files/Logs/Logs/, Files: 0

I either need it to return with some special code or need a function call which tells me if there's anything to export so I can enable / disable the button. Currently the QA testers report this as a bug to me because they are clicking on the button and "nothing is happening". I'd like to display a dialog if there's nothing to export.

can't extract logs to file on IOS 14.3

i am test on IOS 14.3

init
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: "workspaceLogs",
      logsExportDirectoryName: "workspaceLogs/Exported",
      debugFileOperations: true,
      isDebuggable: true);

add logs test:

FlutterLogs.logInfo(TAG, "DebugScreen", "setUpLogs: Setting up logs..");

save file

    var now = new DateTime.now();
    var formatter = new DateFormat('ddMMyH');
    String formattedDate = formatter.format(now);
    String logName = formattedDate;
    print(formattedDate);
    FlutterLogs.logToFile(
        logFileName: logName,
        overwrite: true,
        //If set 'true' logger will append instead of overwriting
        logMessage:
            "This is a log message: ${DateTime.now().millisecondsSinceEpoch}, it will be saved to my log file named: ",
        appendTimeStamp: true);

but no file any

Sensitive log folder name

If I happen to name my folders as:

logsWriteDirectoryName: "Logs",
logsExportDirectoryName: "Logs/Exported",

the plugin will get into an infinite loop like Logs/Exported/Temp/Logs/Exported/Temp/...

flutter_logs does not support flutter_web?

Hi, I have an app that uses flutter_logs and have recently upgraded to flutter 2.

I wanted to try out flutter web but when I build and run the app, I get the error:

MissingPluginException(No implementation found for method initLogs on channel flutter_logs)

The app works fine on Android as I have a few live systems using it now.

Do you know of any reason why this shouldn't work with flutter web?

Version info:

Flutter (Channel beta, 2.0.1, on Linux, locale en_GB.UTF-8)
Android toolchain - develop for Android devices (Android SDK version 28.0.3)

Great work on the package btw - so far the best logging tool I've used with flutter.

Please let me know if you need any more info.

PlatformException while setting meta info

When trying to set the meta info a PlatformException occurs:

PlatformException (PlatformException(error, empty String, null, java.lang.NumberFormatException: empty String
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
    at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    at java.lang.Double.parseDouble(Double.java:538)
    at com.flutter.logs.plogs.flutter_logs.LogsHelper.setupForELKStack(LogsHelper.kt:156)
    at com.flutter.logs.plogs.flutter_logs.FlutterLogsPlugin$Companion.setUpPluginMethods$lambda-0(FlutterLogsPlugin.kt:150)
    at com.flutter.logs.plogs.flutter_logs.FlutterLogsPlugin$Companion.$r8$lambda$KCO-SFXW70ZXiuPV_Lwf9VhDIMM(Unknown Source:0)
    at com.flutter.logs.plogs.flutter_logs.FlutterLogsPlugin$Companion$$ExternalSyntheticLambda0.onMethodCall(Unknown Source:2)
    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
    at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
    at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
    at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7839)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
))

It happens no matter what arguments are being set and how.

initLogs options documentation

Options passed to initLogs() aren't documented anywhere as far as I can tell. If they are, the docs are really well hidden and should be linked to in the project readme.

I tried following the example in the readme, but am struggling to understand how I can customize the default configuration. What does logTypesEnabled do? What about debugFileOperations or isDebuggable? How can I setup log rotation? What about encryption?

This library seems to have a lot of great features, but they're very hard to configure without documentation.

Write given log type only into log file

I want to write error log or info log or both into the log file. It'll be according to users preferences. I've set value into logLevelsEnabled. But Flutter_logs all time writes all types of log into log file. How could I write only given types of logs into log file?

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

D/AlarmPingSender( 4975): Register alarmreceiver to MqttServiceMqttService.pingSender.paho134687483713410
E/AndroidRuntime( 4975): FATAL EXCEPTION: MQTT Rec: paho134687483713410
E/AndroidRuntime( 4975): Process: kontur.io.live_sensors, PID: 4975
E/AndroidRuntime( 4975): java.lang.IllegalArgumentException: kontur.io.live_sensors: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime( 4975): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
E/AndroidRuntime( 4975): 	at android.app.PendingIntent.checkFlags(PendingIntent.java:378)
E/AndroidRuntime( 4975): 	at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:648)
E/AndroidRuntime( 4975): 	at android.app.PendingIntent.getBroadcast(PendingIntent.java:635)
E/AndroidRuntime( 4975): 	at org.eclipse.paho.android.service.AlarmPingSender.start(AlarmPingSender.java:76)
E/AndroidRuntime( 4975): 	at org.eclipse.paho.client.mqttv3.internal.ClientState.connected(ClientState.java:1209)
E/AndroidRuntime( 4975): 	at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:1045)
E/AndroidRuntime( 4975): 	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:151)
E/AndroidRuntime( 4975): 	at java.lang.Thread.run(Thread.java:1012)

Kotlin compilation warnings

Task :flutter_logs:compileReleaseKotlin
w: /home/csaba/.pub-cache/hosted/pub.dartlang.org/flutter_logs-2.1.7/android/src/main/kotlin/com/flutter/logs/plogs/flutter_logs/FlutterLogsPlugin.kt: (148, 29): Variable 'labels' is never used
w: /home/csaba/.pub-cache/hosted/pub.dartlang.org/flutter_logs-2.1.7/android/src/main/kotlin/com/flutter/logs/plogs/flutter_logs/LogsHelper.kt: (64, 68): Type mismatch: inferred type is String? but String was expected

I'm using Kotlin version 1.6.21

check if logs exist

Hi, how would I check if logs are existing? I see the export file and i see a txt file deleted in /private/var/mobile/Containers/Data/Application/30869F15-796E-48E5-AD36-7BXXX0BE8D3/Library/Application%20Support/Logs/Log-2022-01.txt on iOS when I call FlutterLogs.clearLogs(); What is the recommended way to check if logs are there at all?

Could not find com.github.umair13adil:RxLogs:1.0.18. Flutter

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.github.umair13adil:RxLogs:1.0.18.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       - https://repo.maven.apache.org/maven2/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       - https://storage.googleapis.com/download.flutter.io/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       - https://jitpack.io/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       - https://jcenter.bintray.com/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       - https://cardinalcommerceprod.jfrog.io/artifactory/android/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       - https://www.jitpack.io/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       - https://storage.zego.im/maven/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       - https://developer.huawei.com/repo/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       - https://maven.columbus.heytapmobi.com/repository/releases/com/github/umair13adil/RxLogs/1.0.18/RxLogs-1.0.18.pom
       -  Required by:
         project :app > project :flutter_logs

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 53s
Exception: Gradle task assembleDebug failed with exit code 1

How to use flutter_logs with encryption enabled

Hello, I wonder how use correctly this log library enabling encryption.
After saving encrypted logs, I export the zip file without decrypt and send it to my PC.
How can I decrypt the logs inside the zipped file when it's on my PC.
Obviously I have set the encryptionKey. How can I use it?
Is this encryption supported by iOS?

Generate day wise log file

Flutter_logs generates log files day-wise on Android devices but on iOS it generates log files month-wise. For that log file size will be huge(250MB-300MB) which is too much for users. Would you please add the daily log file generation features for iOS?

logFilesLimit???

logFilesLimit means max number of log files.
i can not find anywhere you use logFilesLimit, so it's not written yet?

cannot build after flutter update

Hello,

I am getting following error after flutter update:

pub.dartlang.org\flutter_logs-2.1.5\android\src\main\kotlin\com\flutter\logs\plogs\flutter_logs\FlutterLogsPlugin.kt: (43, 32): Type mismatch: inferred type is Activity? but Context was expected

Any idea?

dependency old?

When I build my flutter app, I got this error.

  • What went wrong:
    Execution failed for task ':flutter_logs:generateReleaseRFile'.

Could not resolve all files for configuration ':flutter_logs:releaseCompileClasspath'.
Could not find com.github.umair13adil:RxLogs:1.0.18.
Required by:
project :flutter_logs

I can confirm the com.github.umair13adil:RxLogs has v1.0.18, as you know. ref) https://github.com/umair13adil/RxLogs/tree/v1.0.18

Could you take a look of this build.gradle? https://github.com/umair13adil/flutter_logs/blob/master/android/build.gradle#L50
Wonder if 1.0.18 fine or not, is it v1.0.18?

Example: Saving to file doesn't work on iOS 14.5.1

Hey, I just wanted to let you know that it seems like your example doesn't work anymore with iOS 14.5.1

When I want to export my logs to a file I get this error message.
Runner[3002:1002604] flutter: flutter_logs: {LogHelper} {getFiles} {No Files found!} {2021-05-10 17:38:56}

best regards,
Alex

Unable To export Log and Share on Android

Unable to export logs and Share on android device, its working fine in ios

I am using this method

Future exportAllLogs() async {
FlutterLogs.exportLogs(exportType: ExportType.ALL);
return _completer.future as FutureOr;
}

but _completer unable to return value ,

Throwing Error on Initialization from non root Isolate. [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Null check operator used on a null value

E/flutter ( 3573): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Null check operator used on a null value
E/flutter ( 3573): #0      MethodChannel.binaryMessenger
package:flutter/…/services/platform_channel.dart:121
E/flutter ( 3573): #1      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:146
E/flutter ( 3573): #2      MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:329
E/flutter ( 3573): #3      FlutterLogs.initLogs
package:flutter_logs/flutter_logs.dart:80
E/flutter ( 3573): #4      ReportingQueue.runRunnable
package:thermal_now/…/reporting_quueue/reporting_queue.dart:82
E/flutter ( 3573): #5      _IsolateConfiguration.apply
package:flutter/…/foundation/_isolates_io.dart:84
E/flutter ( 3573): #6      _spawn.<anonymous closure>
package:flutter/…/foundation/_isolates_io.dart:91
E/flutter ( 3573): #7      _spawn.<anonymous closure>
package:flutter/…/foundation/_isolates_io.dart:90
E/flutter ( 3573): #8      Timeline.timeSync (dart:developer/timeline.dart:163:22)
E/flutter ( 3573): #9      _spawn
package:flutter/…/foundation/_isolates_io.dart:88
E/flutter ( 3573): #10     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:290:17)
E/flutter ( 3573): #11     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:187:12)
E/flutter ( 3573):

support null safety

flutter build apk --debug

Building with sound null safety

Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

  • package:flutter_logs

For solutions, see https://dart.dev/go/unsound-null-safety

FAILURE: Build failed with an exception

Is it possible to define to the full path of where the logs are supposed to be?

Hey,

First of all, great work, I found flutter_logs is the best way to log thing in a flutter app.

My problem is that I store my app files in a complete different folder, and I would like to group every files in one location. I tried to set this option:

logsWriteDirectoryName: await (FileManagement.getLocalPath()),

But it just add the path to this "base" path, and I end up with this log location:

/storage/emulated/0/Android/data/project.package/files/data/user/0/project.package/app_flutter

Or a work around for me would be to have a way to know the actual path of where the logs are?

Thank you for help!

can't write logs to file with file name

var now = new DateTime.now();
    var formatter = new DateFormat('yyyy_MM_dd');
    String formattedDate = formatter.format(now);
    String logName = formattedDate + '_workspacelog';
    print(logName);
    FlutterLogs.logToFile(
      logFileName: logName,
        overwrite: true,
        //If set 'true' logger will append instead of overwriting
        logMessage:
        "This is a log message: ${DateTime.now().millisecondsSinceEpoch}",
        appendTimeStamp: true);

but file save as file name default :
image

the log api save duplicate data

I use iPhone .

if I use logInfo method , it will save duplicate data.

like this:
2021-09-02 13:45:13.696 +0800: {MyLogFile} {This is a log message: 1630561513694, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:45:13.696 +0800: {MyLogFile} {This is a log message: 1630561513694, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:45:13.696 +0800: {MyLogFile} {This is a log message: 1630561513694, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:45:13.696 +0800: {MyLogFile} {This is a log message: 1630561513694, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:45:13.696 +0800: {MyLogFile} {This is a log message: 1630561513694, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:45:13.696 +0800: {MyLogFile} {This is a log message: 1630561513694, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:45:13.696 +0800: {MyLogFile} {This is a log message: 1630561513694, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:46:14.590 +0800: {MyLogFile} {This is a log message: 1630561574586, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:46:14.590 +0800: {MyLogFile} {This is a log message: 1630561574586, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:46:14.590 +0800: {MyLogFile} {This is a log message: 1630561574586, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:46:14.590 +0800: {MyLogFile} {This is a log message: 1630561574586, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:46:14.590 +0800: {MyLogFile} {This is a log message: 1630561574586, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:46:14.590 +0800: {MyLogFile} {This is a log message: 1630561574586, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:46:14.590 +0800: {MyLogFile} {This is a log message: 1630561574586, it will be saved to my log file named: 'MyLogFile'} {false}
2021-09-02 13:48:02.085 +0800: {MyLogFile} {This is a log message: 1630561682083, it will be saved to my log file named: 'MyLogFile'} {true}
2021-09-02 13:48:02.085 +0800: {MyLogFile} {This is a log message: 1630561682083, it will be saved to my log file named: 'MyLogFile'} {true}
2021-09-02 13:48:02.085 +0800: {MyLogFile} {This is a log message: 1630561682083, it will be saved to my log file named: 'MyLogFile'} {true}
2021-09-02 13:48:02.085 +0800: {MyLogFile} {This is a log message: 1630561682083, it will be saved to my log file named: 'MyLogFile'} {true}
2021-09-02 13:48:02.085 +0800: {MyLogFile} {This is a log message: 1630561682083, it will be saved to my log file named: 'MyLogFile'} {true}
2021-09-02 13:48:02.085 +0800: {MyLogFile} {This is a log message: 1630561682083, it will be saved to my log file named: 'MyLogFile'} {true}
2021-09-02 13:48:02.085 +0800: {MyLogFile} {This is a log message: 1630561682083, it will be saved to my log file named: 'MyLogFile'} {true}

setMethodCallHandler callback not getting hit

I'm using the latest version 2.1.10.

When I export the logs, I'm trying to capture the callback to upload file to a server. But the callback registered is not getting hit.

FlutterLogs.channel.setMethodCallHandler((call) async {
      if (call.method == 'logsExported') {
        var zipName = call.arguments.toString();
      } else if (call.method == 'logsPrinted') {
        print(call.arguments.toString());
      }
}

Parse Issue (Xcode): Header 'flutter_logs-Swift.h' not found

build/ios/Debug-iphonesimulator/flutter_logs/flutter_logs.framework/Modules/module.modulemap:8:11

Semantic Issue (Xcode): Use of undeclared identifier 'FlutterLogsPlugin'
/Users/josephjohnson/DEV/NovviaProjects/pickup-director/ios/Runner/GeneratedPluginRegistrant.m:37:3


Could not build the application for the simulator.
Error launching application on iPhone 12.

I see this code refers to a flutter_logs-Swift.h:

#import "FlutterLogsPlugin.h"
#if __has_include(<flutter_logs/flutter_logs-Swift.h>)
#import <flutter_logs/flutter_logs-Swift.h>
#else

I don't see a flutter_logs-Swift.h anywhere

How to setup MQTT along with Server?

I checked the available post on the medium but would this be fine

await FlutterLogs.initMQTT(
topic: "YOUR_TOPIC",
brokerUrl: "", //Add URL without schema
certificate: "m2mqtt_ca.crt",
port: "8883");

Not seems to be working

Namespace error on Gradle 8.0

When you try to build the app using Gradle 8.0 it gives an error saying namespace is not defined for flutter_logs.

If I downgrade the gradle version the app is built and deployed.

Configuration That does not work

classpath 'com.android.tools.build:gradle:8.1.4'
distributionUrl=https://services.gradle.org/distributions/gradle-8.4-all.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.