1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-24 07:38:45 +02:00

Flush logs before sharing

This commit is contained in:
José Rebelo 2024-05-26 15:38:11 +01:00
parent 7b21f85613
commit ef11dd0f16
2 changed files with 11 additions and 0 deletions

View File

@ -67,6 +67,12 @@ public abstract class Logging {
return null;
}
public void setImmediateFlush(final boolean immediateFlush) {
if (fileLogger != null) {
fileLogger.setImmediateFlush(true);
}
}
public boolean isFileLoggerInitialized() {
return logDirectory != null;
}

View File

@ -947,6 +947,11 @@ public class DebugActivity extends AbstractGBActivity {
private void shareLog() {
String fileName = GBApplication.getLogPath();
if (fileName != null && fileName.length() > 0) {
// Flush the logs, so that we ensure latest lines are also there
GBApplication.getLogging().setImmediateFlush(true);
LOG.debug("Flushing logs before sharing");
GBApplication.getLogging().setImmediateFlush(false);
File logFile = new File(fileName);
if (!logFile.exists()) {
GB.toast("File does not exist", Toast.LENGTH_LONG, GB.INFO);