Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MrCsabaToth opened this issue Jun 23, 2022 · 4 comments

Comments

@MrCsabaToth
Copy link
Contributor

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.

@MrCsabaToth
Copy link
Contributor Author

I'm trying to debug this. The problem is that when there are no files, then the FlutterLogs.channel.setMethodCallHandler((call) async { handler (see

FlutterLogs.channel.setMethodCallHandler((call) async {
) is not fired. The case when there are no files is this:

https://github.com/umair13adil/RxLogs/blob/f199b3c89cf510a15b66307c9bf389af4af6fde1/plog/src/main/java/com/blackbox/plog/pLogs/exporter/LogExporter.kt#L110

            if (filesToSend.isEmpty()) {
                if (!emitter.isDisposed)
                    emitter.onError(Throwable("No Files to zip!"))
            }

In fun compressPackage. I'm not sure yet how to bubble that up to the Dart layer, or why is it not bubbling up right now. There's a throwable generated there but I don't see that in Logcat, so it's swallowed somewhere. If I cannot bubble it up then maybe there could be a new call on the API to check if there are files? That might be more work due to API change and RxLogs need to be changed as well.

@MrCsabaToth
Copy link
Contributor Author

There's nothing in Logcat besides I/ExportTypes(20611): getLogsForAllInRoot: Path: /storage/emulated/0/Android/data/dev.csaba.track_my_indoor_exercise/files/Logs/Logs/, Files: 0, and nothing bubbles up.

@MrCsabaToth
Copy link
Contributor Author

Maybe the emitter is disposed? (if (!emitter.isDisposed)). I'd expect to see the "No Files to zip!" in the logs to appear somewhere. The control flow doesn't reach this point either

(or at least I don't see exportPLogs: PLog Error: log entries either in LogCat.

MrCsabaToth added a commit to TrackMyIndoorWorkout/TrackMyIndoorWorkout that referenced this issue Jun 23, 2022
Ugly because now besides file writing there's also a preferences bool set every time something is logged.
@MrCsabaToth MrCsabaToth changed the title FlutterLogs.exportLogs doesn't return (await hangs) if there's 0 files FlutterLogs.exportLogs doesn't return (await hangs) if there are 0 files Jun 26, 2022
MrCsabaToth added a commit to TrackMyIndoorWorkout/TrackMyIndoorWorkout that referenced this issue Jun 26, 2022
Ugly because now besides file writing there's also a preferences bool set every time something is logged.
@ced1check
Copy link
Contributor

Running version 2.1.11 on Android, it seems exportLogs never returns no matter what. I have log files, I can see the ZIP file created fine, but onComplete or then never runs:

    FlutterLogs.exportLogs(exportType: ExportType.ALL).then((value) {
      logInfo(message: 'Finished exporting FlutterLogs...');
    });

Haven't tried on iOS yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants