From 2feb637b9ebff057cda3c0473a99a7d353ebcb19 Mon Sep 17 00:00:00 2001 From: MCleinman <9295855+mcleinman@users.noreply.github.com> Date: Fri, 15 Mar 2024 09:34:24 -0700 Subject: [PATCH] VPN-5101: cleanup logs after they are exported for iOS and desktop (#9231) * VPN-5101 clean up iOS logs * flush on other platforms --- src/loghandler.cpp | 13 ++++--------- src/platforms/ios/ioscommons.mm | 10 ++++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/loghandler.cpp b/src/loghandler.cpp index cf5979f09c..a6f46f218c 100644 --- a/src/loghandler.cpp +++ b/src/loghandler.cpp @@ -449,15 +449,10 @@ bool LogHandler::viewLogs() { return ok; #endif - if (writeAndShowLogs(QStandardPaths::DesktopLocation)) { - return true; - } - - if (writeAndShowLogs(QStandardPaths::HomeLocation)) { - return true; - } - - if (writeAndShowLogs(QStandardPaths::TempLocation)) { + if (writeAndShowLogs(QStandardPaths::DesktopLocation) || + writeAndShowLogs(QStandardPaths::HomeLocation) || + writeAndShowLogs(QStandardPaths::TempLocation)) { + flushLogs(); return true; } diff --git a/src/platforms/ios/ioscommons.mm b/src/platforms/ios/ioscommons.mm index 50e6dc7b3d..779f5b7c44 100644 --- a/src/platforms/ios/ioscommons.mm +++ b/src/platforms/ios/ioscommons.mm @@ -5,6 +5,7 @@ #include "ioscommons.h" #include "constants.h" #include "logger.h" +#include "loghandler.h" #include "qmlengineholder.h" #include @@ -102,6 +103,15 @@ @interface StatusBarModifierViewController : UIViewController activityViewController.popoverPresentationController.sourceRect = CGRectMake(view.bounds.size.width / 2, view.bounds.size.height, 0, 0); } + activityViewController.completionWithItemsHandler = + ^(NSString* activityType, BOOL completed, NSArray* returnedItems, NSError* activityError) { + if (completed) { + logger.info() << "Clearing logs."; + LogHandler::instance()->flushLogs(); + } else { + logger.info() << "No need to clear logs."; + } + }; [qtController presentViewController:activityViewController animated:YES completion:nil]; [activityViewController release]; }