diff --git a/OsmAnd.xcodeproj/project.pbxproj b/OsmAnd.xcodeproj/project.pbxproj index 4901b2b294..c60e5e55f1 100644 --- a/OsmAnd.xcodeproj/project.pbxproj +++ b/OsmAnd.xcodeproj/project.pbxproj @@ -477,6 +477,7 @@ 32EAF9FF2AE15A3C00646807 /* AFNetworkReachabilityManagerWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 32EAF9FE2AE15A3C00646807 /* AFNetworkReachabilityManagerWrapper.m */; }; 32EAFA012AE17F3100646807 /* TravelGuidesSettingsDownloadViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32EAFA002AE17F3100646807 /* TravelGuidesSettingsDownloadViewController.swift */; }; 32EB3DF12AC325780018D9B8 /* OATravelLocalDataDbHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 32EB3DF02AC325780018D9B8 /* OATravelLocalDataDbHelper.mm */; }; + 32F184A32CF8CC78002396E1 /* OALogWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F184A22CF8CC2C002396E1 /* OALogWrapper.swift */; }; 32F6225D29A7AE080069EE04 /* OAAmenityExtendedNameFilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 320EADAB29A77AAB002F9883 /* OAAmenityExtendedNameFilter.mm */; }; 32FE7AA72B65138800F82728 /* OAGPXImportUIHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 32FE7AA62B65138800F82728 /* OAGPXImportUIHelper.mm */; }; 32FF4C292C183B1D00246B36 /* SegmentTableHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 32FF4C252C183A6400246B36 /* SegmentTableHeaderView.xib */; }; @@ -3859,6 +3860,7 @@ 32EB3DEF2AC3256B0018D9B8 /* OATravelLocalDataDbHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OATravelLocalDataDbHelper.h; sourceTree = ""; }; 32EB3DF02AC325780018D9B8 /* OATravelLocalDataDbHelper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = OATravelLocalDataDbHelper.mm; sourceTree = ""; }; 32ECBEAD2657AD7F005D33BD /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/Localizable.strings; sourceTree = ""; }; + 32F184A22CF8CC2C002396E1 /* OALogWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OALogWrapper.swift; sourceTree = ""; }; 32FE7AA52B65136D00F82728 /* OAGPXImportUIHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OAGPXImportUIHelper.h; sourceTree = ""; }; 32FE7AA62B65138800F82728 /* OAGPXImportUIHelper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = OAGPXImportUIHelper.mm; sourceTree = ""; }; 32FF4C252C183A6400246B36 /* SegmentTableHeaderView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SegmentTableHeaderView.xib; sourceTree = ""; }; @@ -10723,6 +10725,7 @@ DA5A79BF26C563A000F274C7 /* main.m */, DA5A79BB26C563A000F274C7 /* OALog.h */, DA5A79C226C563A000F274C7 /* OALog.mm */, + 32F184A22CF8CC2C002396E1 /* OALogWrapper.swift */, DA5A79B726C563A000F274C7 /* OsmAndApp.h */, DA5A79C026C563A000F274C7 /* OsmAndApp.mm */, DA5A79B926C563A000F274C7 /* OsmAndAppCppProtocol.h */, @@ -16780,6 +16783,7 @@ DA5A818326C563A700F274C7 /* OASwitchableAction.m in Sources */, DA5A844A26C563A900F274C7 /* OAHudButton.m in Sources */, 46FB65BA2A8BBC2000A21850 /* CoordinatesMapCenterWidget.swift in Sources */, + 32F184A32CF8CC78002396E1 /* OALogWrapper.swift in Sources */, 32BC95732CC021CE00FEEAB8 /* UIFont+Extension.swift in Sources */, DA5A845526C563A900F274C7 /* OAOsmEditsLayer.mm in Sources */, DA5A815526C563A700F274C7 /* OACarPlayActiveViewController.m in Sources */, diff --git a/Sources/AppHost/CarPlayDelegate/CarPlaySceneDelegates.swift b/Sources/AppHost/CarPlayDelegate/CarPlaySceneDelegates.swift index 2409fe4f1c..21f5df02f7 100644 --- a/Sources/AppHost/CarPlayDelegate/CarPlaySceneDelegates.swift +++ b/Sources/AppHost/CarPlayDelegate/CarPlaySceneDelegates.swift @@ -10,13 +10,13 @@ final class CarPlaySceneDelegate: UIResponder { private var isForegroundScene = false func sceneWillEnterForeground(_ scene: UIScene) { - NSLog("[CarPlay] CarPlaySceneDelegate sceneWillEnterForeground") + OALog("[CarPlay] CarPlaySceneDelegate sceneWillEnterForeground") isForegroundScene = true configureScene() } func sceneWillResignActive(_ scene: UIScene) { - NSLog("[CarPlay] CarPlaySceneDelegate sceneWillResignActive") + OALog("[CarPlay] CarPlaySceneDelegate sceneWillResignActive") NotificationCenter.default.removeObserver(self) isForegroundScene = false } @@ -113,13 +113,13 @@ final class CarPlaySceneDelegate: UIResponder { } @objc private func appInitEventConfigureScene(notification: Notification) { - NSLog("[CarPlay] CarPlaySceneDelegate appInitEventConfigureScene") + OALog("[CarPlay] CarPlaySceneDelegate appInitEventConfigureScene") guard let userInfo = notification.userInfo, let item = userInfo["event"] as? Int, let event = AppLaunchEvent(rawValue: item) else { return } if case .setupRoot = event { guard isForegroundScene else { return } - NSLog("[CarPlay] CarPlaySceneDelegate appInitEventConfigureScene success") + OALog("[CarPlay] CarPlaySceneDelegate appInitEventConfigureScene success") configureScene() } } @@ -127,7 +127,7 @@ final class CarPlaySceneDelegate: UIResponder { extension CarPlaySceneDelegate: CPTemplateApplicationSceneDelegate { func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController, to window: CPWindow) { - NSLog("[CarPlay] CarPlaySceneDelegate didConnect") + OALog("[CarPlay] CarPlaySceneDelegate didConnect") OsmAndApp.swiftInstance().carPlayActive = true windowToAttach = window @@ -135,7 +135,7 @@ extension CarPlaySceneDelegate: CPTemplateApplicationSceneDelegate { } func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didDisconnect interfaceController: CPInterfaceController, from window: CPWindow) { - NSLog("[CarPlay] CarPlaySceneDelegate didDisconnect") + OALog("[CarPlay] CarPlaySceneDelegate didDisconnect") OsmAndApp.swiftInstance().carPlayActive = false if defaultAppMode != nil && !isRoutingActive() { @@ -144,13 +144,13 @@ extension CarPlaySceneDelegate: CPTemplateApplicationSceneDelegate { defaultAppMode = nil guard let mapPanel = OARootViewController.instance()?.mapPanel else { - NSLog("[CarPlay] CarPlaySceneDelegate rootViewController mapPanel is nil") + OALog("[CarPlay] CarPlaySceneDelegate rootViewController mapPanel is nil") return } mapPanel.onCarPlayDisconnected { [weak self] in guard let self else { return } - NSLog("[CarPlay] CarPlaySceneDelegate onCarPlayDisconnected") + OALog("[CarPlay] CarPlaySceneDelegate onCarPlayDisconnected") carPlayMapController?.detachFromCarPlayWindow() carPlayDashboardController = nil carPlayMapController?.navigationController?.popViewController(animated: true) diff --git a/Sources/AppHost/CarPlayDelegate/DashboardCarPlaySceneDelegate.swift b/Sources/AppHost/CarPlayDelegate/DashboardCarPlaySceneDelegate.swift index 7d76fa6f0a..15363e5cbd 100644 --- a/Sources/AppHost/CarPlayDelegate/DashboardCarPlaySceneDelegate.swift +++ b/Sources/AppHost/CarPlayDelegate/DashboardCarPlaySceneDelegate.swift @@ -8,13 +8,13 @@ final class DashboardCarPlaySceneDelegate: UIResponder { private var isForegroundScene = false func sceneWillEnterForeground(_ scene: UIScene) { - NSLog("[CarPlay] DashboardCarPlaySceneDelegate sceneWillEnterForeground") + OALog("[CarPlay] DashboardCarPlaySceneDelegate sceneWillEnterForeground") isForegroundScene = true configureScene() } func sceneWillResignActive(_ scene: UIScene) { - NSLog("[CarPlay] DashboardCarPlaySceneDelegate sceneWillResignActive") + OALog("[CarPlay] DashboardCarPlaySceneDelegate sceneWillResignActive") NotificationCenter.default.removeObserver(self) isForegroundScene = false mapVC?.isCarPlayDashboardActive = false @@ -68,13 +68,13 @@ final class DashboardCarPlaySceneDelegate: UIResponder { } @objc private func appInitEventConfigureScene(notification: Notification) { - NSLog("[CarPlay] DashboardCarPlaySceneDelegate appInitEventConfigureScene") + OALog("[CarPlay] DashboardCarPlaySceneDelegate appInitEventConfigureScene") guard let userInfo = notification.userInfo, let item = userInfo["event"] as? Int, let event = AppLaunchEvent(rawValue: item) else { return } if case .setupRoot = event { guard isForegroundScene else { return } - NSLog("[CarPlay] DashboardCarPlaySceneDelegate appInitEventConfigureScene success") + OALog("[CarPlay] DashboardCarPlaySceneDelegate appInitEventConfigureScene success") configureScene() } } @@ -83,7 +83,7 @@ final class DashboardCarPlaySceneDelegate: UIResponder { extension DashboardCarPlaySceneDelegate: CPTemplateApplicationDashboardSceneDelegate { func templateApplicationDashboardScene(_ templateApplicationDashboardScene: CPTemplateApplicationDashboardScene, didConnect dashboardController: CPDashboardController, to window: UIWindow) { - NSLog("[CarPlay] DashboardCarPlaySceneDelegate didConnect") + OALog("[CarPlay] DashboardCarPlaySceneDelegate didConnect") self.window = window dashboardController.shortcutButtons = [ CPDashboardButton(titleVariants: [localizedString("shared_string_navigation")], subtitleVariants: [""], image: UIImage(named: "ic_carplay_navigation")!, handler: { _ in @@ -97,7 +97,7 @@ extension DashboardCarPlaySceneDelegate: CPTemplateApplicationDashboardSceneDele } func templateApplicationDashboardScene(_ templateApplicationDashboardScene: CPTemplateApplicationDashboardScene, didDisconnect dashboardController: CPDashboardController, from window: UIWindow) { - NSLog("[CarPlay] DashboardCarPlaySceneDelegate didDisconnect") + OALog("[CarPlay] DashboardCarPlaySceneDelegate didDisconnect") dashboardVC?.detachFromCarPlayWindow() mapVC = nil self.window = nil diff --git a/Sources/AppHost/OAAppDelegate.mm b/Sources/AppHost/OAAppDelegate.mm index 44f5915a7e..71f3836868 100644 --- a/Sources/AppHost/OAAppDelegate.mm +++ b/Sources/AppHost/OAAppDelegate.mm @@ -77,7 +77,7 @@ - (instancetype)init self = [super init]; if (self) { - NSLog(@"AppDelegate initialized"); + OALog(@"AppDelegate initialized"); initializeQueue = dispatch_queue_create("OAAppDelegateInitializeQueue", dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_CONCURRENT, QOS_CLASS_USER_INTERACTIVE, 0)); } return self; @@ -105,7 +105,7 @@ - (BOOL)initialize [self configureAppLaunchEvent:AppLaunchEventStart]; - NSLog(@"OAAppDelegate initialize start"); + OALog(@"OAAppDelegate initialize start"); // Configure device UIDevice* device = [UIDevice currentDevice]; @@ -133,19 +133,19 @@ - (BOOL)initialize dispatch_async(initializeQueue, ^{ - NSLog(@"OAAppDelegate beginBackgroundTask"); + OALog(@"OAAppDelegate beginBackgroundTask"); // Initialize OsmAnd core if (![_app initializeCore]) { - NSLog(@"OAAppDelegate failed to initialize core"); + OALog(@"OAAppDelegate failed to initialize core"); return; } // Initialize application in background if (![_app initialize]) { - NSLog(@"OAAppDelegate failed to initialize app"); + OALog(@"OAAppDelegate failed to initialize app"); return; } @@ -199,14 +199,14 @@ - (BOOL)initialize [[UIApplication sharedApplication] endBackgroundTask:_appInitTask]; _appInitTask = UIBackgroundTaskInvalid; - NSLog(@"OAAppDelegate endBackgroundTask"); + OALog(@"OAAppDelegate endBackgroundTask"); // Check for updates every hour when the app is in the foreground [self initCheckUpdatesTimer]; }); }); - NSLog(@"OAAppDelegate initialize finish"); + OALog(@"OAAppDelegate initialize finish"); return YES; } @@ -284,14 +284,14 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( _dataFetchQueue = [[NSOperationQueue alloc] init]; @try { - NSLog(@"BGTaskScheduler registerForTaskWithIdentifier"); + OALog(@"BGTaskScheduler registerForTaskWithIdentifier"); [BGTaskScheduler.sharedScheduler registerForTaskWithIdentifier:kFetchDataUpdatesId usingQueue:nil launchHandler:^(__kindof BGTask * _Nonnull task) { [self handleBackgroundDataFetch:(BGProcessingTask *)task]; }]; } @catch (NSException *e) { - NSLog(@"Failed to schedule background fetch. Reason: %@", e.reason); + OALog(@"Failed to schedule background fetch. Reason: %@", e.reason); } } @@ -322,14 +322,14 @@ - (void)scheduleBackgroundDataFetch request.earliestBeginDate = [NSDate dateWithTimeIntervalSinceNow:kCheckUpdatesInterval]; @try { - NSLog(@"BGTaskScheduler submitTaskRequest"); + OALog(@"BGTaskScheduler submitTaskRequest"); NSError *error = nil; // e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"net.osmand.fetchDataUpdates"] [BGTaskScheduler.sharedScheduler submitTaskRequest:request error:&error]; if (error) - NSLog(@"Could not schedule app refresh: %@", error.description); + OALog(@"Could not schedule app refresh: %@", error.description); } @catch (NSException *e) { - NSLog(@"Could not schedule app refresh: %@", e.reason); + OALog(@"Could not schedule app refresh: %@", e.reason); } } @@ -340,14 +340,14 @@ - (void)application:(UIApplication *)application handleEventsForBackgroundURLSes - (void)applicationWillResignActive { - NSLog(@"OAAppDelegate applicationWillResignActive %d", _appInitDone); + OALog(@"OAAppDelegate applicationWillResignActive %d", _appInitDone); if (_appInitDone) [_app onApplicationWillResignActive]; } - (void)applicationDidEnterBackground { - NSLog(@"OAAppDelegate applicationDidEnterBackground %d", _appInitDone); + OALog(@"OAAppDelegate applicationDidEnterBackground %d", _appInitDone); [self invalidateIfNeededCheckUpdatesTimer]; if (_appInitDone) [_app onApplicationDidEnterBackground]; @@ -358,7 +358,7 @@ - (void)applicationDidEnterBackground - (void)applicationWillEnterForeground { - NSLog(@"OAAppDelegate applicationWillEnterForeground %d", _appInitDone); + OALog(@"OAAppDelegate applicationWillEnterForeground %d", _appInitDone); if (_appInitDone) { [_app onApplicationWillEnterForeground]; @@ -369,7 +369,7 @@ - (void)applicationWillEnterForeground id nextTask = [_app.downloadsManager firstDownloadTasksWithKey:[_app.downloadsManager.keysOfDownloadTasks objectAtIndex:0]]; if (nextTask) { - NSLog(@"Resume suspended download %@", nextTask.key); + OALog(@"Resume suspended download %@", nextTask.key); [nextTask resume]; } } @@ -378,7 +378,7 @@ - (void)applicationWillEnterForeground - (void)applicationDidBecomeActive { - NSLog(@"OAAppDelegate applicationDidBecomeActive %d", _appInitDone); + OALog(@"OAAppDelegate applicationDidBecomeActive %d", _appInitDone); if (_appInitDone) { [self initCheckUpdatesTimer]; @@ -394,7 +394,7 @@ - (void)initCheckUpdatesTimer - (void)applicationWillTerminate:(UIApplication *)application { - NSLog(@"OAAppDelegate applicationWillTerminate"); + OALog(@"OAAppDelegate applicationWillTerminate"); [_app shutdown]; OAMapViewController *mapVc = OARootViewController.instance.mapPanel.mapViewController; [mapVc onApplicationDestroyed]; @@ -409,17 +409,17 @@ - (void)applicationWillTerminate:(UIApplication *)application - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { - NSLog(@"OAAppDelegate applicationDidReceiveMemoryWarning"); + OALog(@"OAAppDelegate applicationDidReceiveMemoryWarning"); } - (void)applicationProtectedDataWillBecomeUnavailable:(UIApplication *)application { - NSLog(@"OAAppDelegate applicationProtectedDataWillBecomeUnavailable"); + OALog(@"OAAppDelegate applicationProtectedDataWillBecomeUnavailable"); } - (void)applicationProtectedDataDidBecomeAvailable:(UIApplication *)application { - NSLog(@"OAAppDelegate applicationProtectedDataDidBecomeAvailable"); + OALog(@"OAAppDelegate applicationProtectedDataDidBecomeAvailable"); } #pragma mark - UISceneSession Lifecycle diff --git a/Sources/AppHost/OAFetchBackgroundDataOperation.m b/Sources/AppHost/OAFetchBackgroundDataOperation.m index ca7b40a16e..670a17388c 100644 --- a/Sources/AppHost/OAFetchBackgroundDataOperation.m +++ b/Sources/AppHost/OAFetchBackgroundDataOperation.m @@ -12,6 +12,7 @@ #import "OAAutoObserverProxy.h" #import "OAObservable.h" #import "OADownloadTask.h" +#import "OALog.h" #import @implementation OAFetchBackgroundDataOperation @@ -58,11 +59,11 @@ - (void) onBackgroundDownloadCanceled - (void) performUpdatesCheck { - NSLog(@"OAFetchBackgroundDataOperation start"); + OALog(@"OAFetchBackgroundDataOperation start"); [_app checkAndDownloadOsmAndLiveUpdates:NO]; - NSLog(@"OAFetchBackgroundDataOperation LiveUpdates checked"); + OALog(@"OAFetchBackgroundDataOperation LiveUpdates checked"); OADownloadsManager *downloadManager = _app.downloadsManager; BOOL hasNetworkConnection = NO; @@ -73,46 +74,46 @@ - (void) performUpdatesCheck hasNetworkConnection = AFNetworkReachabilityManager.sharedManager.isReachable; hasTasks = [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"] > 0; - NSLog(@"OAFetchBackgroundDataOperation processing live tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"]); + OALog(@"OAFetchBackgroundDataOperation processing live tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"]); } while (hasNetworkConnection && hasTasks && !self.cancelled); if (self.cancelled && hasTasks) { - NSLog(@"OAFetchBackgroundDataOperation LiveUpdates cancel tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"]); + OALog(@"OAFetchBackgroundDataOperation LiveUpdates cancel tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"]); NSArray *tasks = [downloadManager downloadTasksWithKeySuffix:@".live.obf"]; for (id task in tasks) [task cancel]; } - NSLog(@"OAFetchBackgroundDataOperation LiveUpdates done"); + OALog(@"OAFetchBackgroundDataOperation LiveUpdates done"); if (!self.cancelled && hasNetworkConnection) { [_app checkAndDownloadWeatherForecastsUpdates]; - NSLog(@"OAFetchBackgroundDataOperation ForecastsUpdates checked"); + OALog(@"OAFetchBackgroundDataOperation ForecastsUpdates checked"); do { [NSThread sleepForTimeInterval:0.5]; hasNetworkConnection = AFNetworkReachabilityManager.sharedManager.isReachable; hasTasks = [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"] > 0; - NSLog(@"OAFetchBackgroundDataOperation processing forecasts tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"]); + OALog(@"OAFetchBackgroundDataOperation processing forecasts tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"]); } while (hasNetworkConnection && hasTasks && !self.cancelled); if (self.cancelled && hasTasks) { - NSLog(@"OAFetchBackgroundDataOperation ForecastsUpdates cancel tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"]); + OALog(@"OAFetchBackgroundDataOperation ForecastsUpdates cancel tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"]); NSArray *tasks = [downloadManager downloadTasksWithKeySuffix:@"tifsqlite"]; for (id task in tasks) [task cancel]; } - NSLog(@"OAFetchBackgroundDataOperation ForecastsUpdates done"); + OALog(@"OAFetchBackgroundDataOperation ForecastsUpdates done"); } - NSLog(@"OAFetchBackgroundDataOperation finish"); + OALog(@"OAFetchBackgroundDataOperation finish"); } @end diff --git a/Sources/AppHost/OALog.h b/Sources/AppHost/OALog.h index 1793552a55..5c89e8c1f1 100644 --- a/Sources/AppHost/OALog.h +++ b/Sources/AppHost/OALog.h @@ -8,14 +8,34 @@ #import +typedef NS_ENUM(NSUInteger, EOALog) { + EOALogVerbose, + EOALogDebug, + EOALogInfo, + EOALogWarning, + EOALogError +}; + + #if __cplusplus extern "C" { #endif + void OALogWithLevel(EOALog level, NSString *format, ...); void OALog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); #if __cplusplus } #endif + @interface OALogger : NSObject + ++ (void) log:(NSString *)format withArguments:(va_list)arguments; + ++ (void) createLogFileIfNeeded; + ++ (NSString *) getFormattedTimestamp; ++ (NSString *) getFormattedTimestampByDate:(NSDate *)date; ++ (NSString *) getFormattedThread:(NSThread *)thread; + @end diff --git a/Sources/AppHost/OALog.mm b/Sources/AppHost/OALog.mm index 088fe14282..11483d7524 100644 --- a/Sources/AppHost/OALog.mm +++ b/Sources/AppHost/OALog.mm @@ -13,6 +13,21 @@ #include #include +#include + +/// set YES for printing logs without timestamp and thread name +static const BOOL useShortFormat = NO; + +/// overwrite to YES to write log file in debug device. (while device is diconnected from XCode). +/// warning: set to YES only for diconnected device debugging time. if you connect device back to XCode, in this mode all logs printed in file will not appear in XCode console (because that's how freopen() works) +static BOOL shouldWriteToLogFileInDubug = NO; + +/// overwrite to YES to stop deleting old log files in debug device. +static BOOL shouldSaveOldLogFiles = NO; + +static int maxLogFilesCount = 3; + + #if __cplusplus extern "C" { @@ -21,20 +36,153 @@ void OALog(NSString *format, ...) { va_list args; va_start(args, format); - NSString* formattedString = [[NSString alloc] initWithFormat:format - arguments:args]; + NSString* formattedString = [[NSString alloc] initWithFormat:format arguments:args]; + va_end(args); + NSCAssert((formattedString != nil), @"Log formatting failed"); + OALogWithLevel(EOALogInfo, formattedString); + } + + void OALogWithLevel(EOALog level, NSString *format, ...) + { + va_list args; + va_start(args, format); + NSString* formattedString = [[NSString alloc] initWithFormat:format arguments:args]; va_end(args); NSCAssert((formattedString != nil), @"Log formatting failed"); + + if (!useShortFormat) + { + NSString *timestamp = [OALogger getFormattedTimestamp]; + NSString *threadInfo = [OALogger getFormattedThread:[NSThread currentThread]]; + formattedString = [NSString stringWithFormat:@"%@ %@ %@", + timestamp, + threadInfo, + formattedString]; + } const char* pcsFormattedString = [formattedString cStringUsingEncoding:NSASCIIStringEncoding]; + OsmAnd::LogSeverityLevel cppLogLevel; + if (level == EOALogVerbose) + cppLogLevel = OsmAnd::LogSeverityLevel::Verbose; + else if (level == EOALogDebug) + cppLogLevel = OsmAnd::LogSeverityLevel::Debug; + else if (level == EOALogInfo) + cppLogLevel = OsmAnd::LogSeverityLevel::Info; + else if (level == EOALogWarning) + cppLogLevel = OsmAnd::LogSeverityLevel::Warning; + else if (level == EOALogError) + cppLogLevel = OsmAnd::LogSeverityLevel::Error; + if (pcsFormattedString != nullptr) - OsmAnd::Logger::get()->log(OsmAnd::LogSeverityLevel::Info, "%s", pcsFormattedString); + OsmAnd::Logger::get()->log(cppLogLevel, "%s", pcsFormattedString); else - OsmAnd::Logger::get()->log(OsmAnd::LogSeverityLevel::Info, "%s", qPrintable(QString::fromNSString(formattedString))); + OsmAnd::Logger::get()->log(cppLogLevel, "%s", qPrintable(QString::fromNSString(formattedString))); } #if __cplusplus } #endif + @implementation OALogger -@end \ No newline at end of file + +static NSDateFormatter *_dateFormatter; + +// wrapper for using OALog() from swift ++ (void) log:(NSString *)format withArguments:(va_list)args; +{ + NSString *logString = [[NSString alloc] initWithFormat:format arguments:args]; + OALog(@"%@", logString); +} + ++ (void) createLogFileIfNeeded +{ + BOOL shouldCreateLogFile = NO; + #if DEBUG + shouldCreateLogFile = shouldWriteToLogFileInDubug; + #else + shouldCreateLogFile = YES; + #endif + + if (shouldCreateLogFile) + [self createLogFile]; +} + ++ (void) createLogFile +{ + NSFileManager *manager = NSFileManager.defaultManager; + NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; + NSString *logsPath = [documentsPath stringByAppendingPathComponent:@"Logs"]; + if (![manager fileExistsAtPath:logsPath]) + [manager createDirectoryAtPath:logsPath withIntermediateDirectories:NO attributes:nil error:nil]; + NSArray *files = [manager contentsOfDirectoryAtPath:logsPath error:nil]; + + files = [[[files sortedArrayUsingComparator:^NSComparisonResult(NSString *filename1, NSString *filename2) { + return [filename1 compare:filename2]; + }] reverseObjectEnumerator] allObjects]; + + if (!shouldSaveOldLogFiles) + { + for (NSInteger i = 0; i < files.count; i++) + { + if (i > maxLogFilesCount) + [manager removeItemAtPath:[logsPath stringByAppendingPathComponent:files[i]] error:nil]; + } + } + + [[self dateFormatter] setDateFormat:@"MMM dd, yyyy HH:mm:ss"]; + NSString *destPath = [[logsPath stringByAppendingPathComponent:[[self dateFormatter] stringFromDate:NSDate.date]] stringByAppendingPathExtension:@"log"]; + + freopen([destPath fileSystemRepresentation], "a+", stdout); + freopen([destPath fileSystemRepresentation], "a+", stderr); +} + ++ (NSString *) getFormattedTimestamp +{ + return [self getFormattedTimestampByDate:[NSDate now]]; +} + ++ (NSString *) getFormattedTimestampByDate:(NSDate *)date +{ + [[self dateFormatter] setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSSS"]; + return [[self dateFormatter] stringFromDate:date]; +} + ++ (NSDateFormatter *)dateFormatter +{ + if (!_dateFormatter) + _dateFormatter = [[NSDateFormatter alloc] init]; + return _dateFormatter; +} + ++ (NSString *) getFormattedThread:(NSThread *)thread +{ + BOOL isMain = [thread isMainThread]; + NSString *name = thread.name; + name = (name && name.length > 0) ? [NSString stringWithFormat:@" \"%@\"", thread.name] : @""; + NSString *quality = [self formattedQualityOfServise:thread.qualityOfService]; + mach_port_t machTID = pthread_mach_thread_np(pthread_self()); + + return [NSString stringWithFormat:@"[%@ %d%@%@]", + isMain ? @"MainThread" : @"Thread", + machTID, + name, + quality]; +} + ++ (NSString *) formattedQualityOfServise:(NSQualityOfService)quality +{ + switch (quality) { + case NSQualityOfServiceUserInteractive: + return @""; + case NSQualityOfServiceUserInitiated: + return @" Initiated"; + case NSQualityOfServiceUtility: + return @" Utility"; + case NSQualityOfServiceBackground: + return @" Background"; + default: + return @" Default"; + } +} + +@end diff --git a/Sources/AppHost/OALogWrapper.swift b/Sources/AppHost/OALogWrapper.swift new file mode 100644 index 0000000000..6b58a00e1d --- /dev/null +++ b/Sources/AppHost/OALogWrapper.swift @@ -0,0 +1,13 @@ +// +// OALogWrapper.swift +// OsmAnd +// +// Created by Max Kojin on 28/11/24. +// Copyright © 2024 OsmAnd. All rights reserved. +// + +import Foundation + +func OALog(_ format: String, _ arguments: CVarArg...) { + withVaList(arguments) { OALogger.log(format, withArguments: $0) } +} diff --git a/Sources/AppHost/OsmAndAppImpl.mm b/Sources/AppHost/OsmAndAppImpl.mm index 604423ab79..d9130f5afb 100644 --- a/Sources/AppHost/OsmAndAppImpl.mm +++ b/Sources/AppHost/OsmAndAppImpl.mm @@ -82,8 +82,6 @@ #define VERSION_4_4_1 4.41 #define VERSION_4_7_4 4.74 -#define kMaxLogFiles 3 - #define kAppData @"app_data" #define kSubfolderPlaceholder @"_%_" #define kBuildVersion @"buildVersion" @@ -187,7 +185,7 @@ - (instancetype) init _legacyFavoritesFilePrefix = @"favourites"; [self buildFolders]; - [self createLogFile]; + [OALogger createLogFileIfNeeded]; [self initOpeningHoursParser]; @@ -234,28 +232,6 @@ - (void)createFolderIfNeeded:(NSString *)path } } -- (void) createLogFile -{ -#if DEBUG - return; -#else - NSFileManager *manager = NSFileManager.defaultManager; - NSString *logsPath = [_documentsPath stringByAppendingPathComponent:@"Logs"]; - if (![manager fileExistsAtPath:logsPath]) - [manager createDirectoryAtPath:logsPath withIntermediateDirectories:NO attributes:nil error:nil]; - NSArray *files = [manager contentsOfDirectoryAtPath:logsPath error:nil]; - for (NSInteger i = 0; i < files.count; i++) - { - if (i > kMaxLogFiles) - [manager removeItemAtPath:[logsPath stringByAppendingPathComponent:files[i]] error:nil]; - } - NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; - [formatter setDateFormat:@"MMM dd, yyyy HH:mm"]; - NSString *destPath = [[logsPath stringByAppendingPathComponent:[formatter stringFromDate:NSDate.date]] stringByAppendingPathExtension:@"log"]; - freopen([destPath fileSystemRepresentation], "a+", stderr); -#endif -} - - (void) initOpeningHoursParser { [OAExternalTimeFormatter setLocale:[NSLocale currentLocale].localeIdentifier]; @@ -324,23 +300,23 @@ - (BOOL) initializeCore { if (_initializedCore) { - NSLog(@"OsmAndApp Core already initialized. Finish."); + OALog(@"OsmAndApp Core already initialized. Finish."); return YES; } @try { // Initialize OsmAnd Core - NSLog(@"OsmAndApp InitializeCore start"); + OALog(@"OsmAndApp InitializeCore start"); const std::shared_ptr coreResourcesFromBundleProvider(new CoreResourcesFromBundleProvider()); OsmAnd::InitializeCore(coreResourcesFromBundleProvider); _initializedCore = YES; - NSLog(@"OsmAndApp InitializeCore finish"); + OALog(@"OsmAndApp InitializeCore finish"); return YES; } @catch (NSException *e) { - NSLog(@"Failed to InitializeCore. Reason: %@", e.reason); + OALog(@"Failed to InitializeCore. Reason: %@", e.reason); return NO; } } @@ -356,7 +332,7 @@ - (BOOL) initialize } @catch (NSException *e) { - NSLog(@"Failed to initialize OsmAndApp. Reason: %@", e.reason); + OALog(@"Failed to initialize OsmAndApp. Reason: %@", e.reason); return NO; } } @@ -364,10 +340,10 @@ - (BOOL) initialize - (BOOL) initializeImpl { - NSLog(@"OsmAndApp initialize start (%@)", [NSThread isMainThread] ? @"Main thread" : @"Background thread"); + OALog(@"OsmAndApp initialize start (%@)", [NSThread isMainThread] ? @"Main thread" : @"Background thread"); if (_initialized) { - NSLog(@"OsmAndApp already initialized. Finish."); + OALog(@"OsmAndApp already initialized. Finish."); return YES; } @@ -599,7 +575,7 @@ - (BOOL) initializeImpl NSError *error = nil; [[NSFileManager defaultManager] copyItemAtPath:ocbfPathBundle toPath:ocbfPathLib error:&error]; if (error) - NSLog(@"Error copying file: %@ to %@ - %@", ocbfPathBundle, ocbfPathLib, [error localizedDescription]); + OALog(@"Error copying file: %@ to %@ - %@", ocbfPathBundle, ocbfPathLib, [error localizedDescription]); } [self applyExcludedFromBackup:ocbfPathLib]; @@ -613,12 +589,12 @@ - (BOOL) initializeImpl [[NSFileManager defaultManager] createDirectoryAtPath:[NSHomeDirectory() stringByAppendingString:@"/Library/Application Support/proj"] withIntermediateDirectories:YES attributes:nil error:&errorDir]; if (errorDir) - NSLog(@"Error creating dir for proj: %@", [errorDir localizedDescription]); + OALog(@"Error creating dir for proj: %@", [errorDir localizedDescription]); NSError *error = nil; [[NSFileManager defaultManager] copyItemAtPath:projDbPathBundle toPath:projDbPathLib error:&error]; if (error) - NSLog(@"Error copying file: %@ to %@ - %@", projDbPathBundle, projDbPathLib, [error localizedDescription]); + OALog(@"Error copying file: %@ to %@ - %@", projDbPathBundle, projDbPathLib, [error localizedDescription]); } [self applyExcludedFromBackup:projDbPathLib]; @@ -741,7 +717,7 @@ - (BOOL) initializeImpl return NO; _initialized = YES; - NSLog(@"OsmAndApp initialize finish"); + OALog(@"OsmAndApp initialize finish"); return YES; } @@ -885,7 +861,7 @@ - (void) clearUnsupportedTilesCache { NSString *pathToCache = [self.cachePath stringByAppendingPathComponent:folderName]; BOOL success = [manager removeItemAtPath:pathToCache error:nil]; - NSLog(@"Removing tiles at path: %@ %@", pathToCache, success ? @"successful" : @"failed - No such directory"); + OALog(@"Removing tiles at path: %@ %@", pathToCache, success ? @"successful" : @"failed - No such directory"); } } @@ -909,7 +885,7 @@ - (void) clearUnsupportedTilesCache { float te = [[NSDate date] timeIntervalSince1970]; if (te - tm > 30) - NSLog(@"Defalt routing config init took %f ms", (te - tm)); + OALog(@"Defalt routing config init took %f ms", (te - tm)); } } @@ -1071,12 +1047,12 @@ - (void) checkAndDownloadOsmAndLiveUpdates:(BOOL)checkUpdatesAsync @synchronized (self) { - NSLog(@"Prepare checkAndDownloadOsmAndLiveUpdates start"); + OALog(@"Prepare checkAndDownloadOsmAndLiveUpdates start"); QList > updates; for (const auto& localResource : _resourcesManager->getLocalResources()) [OAOsmAndLiveHelper downloadUpdatesForRegion:QString(localResource->id).remove(QStringLiteral(".obf")) resourcesManager:_resourcesManager checkUpdatesAsync:checkUpdatesAsync]; - NSLog(@"Prepare checkAndDownloadOsmAndLiveUpdates finish"); + OALog(@"Prepare checkAndDownloadOsmAndLiveUpdates finish"); } } @@ -1087,11 +1063,11 @@ - (void) checkAndDownloadWeatherForecastsUpdates @synchronized (self) { - NSLog(@"Prepare checkAndDownloadWeatherForecastsUpdates start"); + OALog(@"Prepare checkAndDownloadWeatherForecastsUpdates start"); OAWeatherHelper *weatherHelper = [OAWeatherHelper sharedInstance]; NSArray *regionIds = [weatherHelper getRegionIdsForDownloadedWeatherForecast]; [weatherHelper checkAndDownloadForecastsByRegionIds:regionIds]; - NSLog(@"Prepare checkAndDownloadWeatherForecastsUpdates finish"); + OALog(@"Prepare checkAndDownloadWeatherForecastsUpdates finish"); } } diff --git a/Sources/AppHost/SceneDelegate.mm b/Sources/AppHost/SceneDelegate.mm index b461500c21..ebb98e707f 100644 --- a/Sources/AppHost/SceneDelegate.mm +++ b/Sources/AppHost/SceneDelegate.mm @@ -71,16 +71,16 @@ - (instancetype)init self = [super init]; if (self) { - NSLog(@"SceneDelegate initialized"); + OALog(@"SceneDelegate initialized"); } return self; } - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { - NSLog(@"SceneDelegate willConnectToSession"); + OALog(@"SceneDelegate willConnectToSession"); _windowScene = (UIWindowScene *)scene; if (!_windowScene) { - NSLog(@"SceneDelegate _windowScene in nil"); + OALog(@"SceneDelegate _windowScene in nil"); return; } @@ -143,7 +143,7 @@ - (void)launchUpdateStateNotification:(NSNotification *)notification NSDictionary *info = notification.userInfo; if (info[@"event"]) { NSNumber *num = info[@"event"]; - NSLog(@"launchUpdateStateNotification: %@", num); + OALog(@"launchUpdateStateNotification: %@", num); [self configureSceneState:(AppLaunchEvent)num.intValue]; } } @@ -152,16 +152,16 @@ - (void)configureSceneState:(AppLaunchEvent)event { switch (event) { case AppLaunchEventStart: - NSLog(@"AppLaunchEventStart"); + OALog(@"AppLaunchEventStart"); _window.rootViewController = [OALaunchScreenViewController new]; [_window makeKeyAndVisible]; break; case AppLaunchEventFirstLaunch: - NSLog(@"AppLaunchEventFirstLaunch"); + OALog(@"AppLaunchEventFirstLaunch"); [_rootViewController.navigationController pushViewController:[OAFirstUsageWizardController new] animated:NO]; break; case AppLaunchEventRestoreSession: - NSLog(@"AppLaunchEventRestoreSession"); + OALog(@"AppLaunchEventRestoreSession"); _rootViewController = [OARootViewController new]; if ([self appDelegate].rootViewController == nil) [self appDelegate].rootViewController = _rootViewController; @@ -170,7 +170,7 @@ - (void)configureSceneState:(AppLaunchEvent)event [_window makeKeyAndVisible]; break; case AppLaunchEventSetupRoot: - NSLog(@"AppLaunchEventSetupRoot"); + OALog(@"AppLaunchEventSetupRoot"); [self configureLaunchEventSetupRootState]; break; default: diff --git a/Sources/Backup/LocalBackup/ImportExportData/ReadWrite/OASettingsItemReader.m b/Sources/Backup/LocalBackup/ImportExportData/ReadWrite/OASettingsItemReader.m index 7f99983f38..72754edbe9 100644 --- a/Sources/Backup/LocalBackup/ImportExportData/ReadWrite/OASettingsItemReader.m +++ b/Sources/Backup/LocalBackup/ImportExportData/ReadWrite/OASettingsItemReader.m @@ -9,6 +9,7 @@ #import "OASettingsItemReader.h" #import "OASettingsHelper.h" #import "OASettingsItem.h" +#import "OALog.h" @interface OASettingsItemReader<__covariant ObjectType : OASettingsItem *>() @@ -67,7 +68,7 @@ - (BOOL) readFromFile:(NSString *)filePath error:(NSError * _Nullable *)error [self.item readFromJson:json error:&parsingError]; if (parsingError) { - NSLog(@"Json parsing error"); + OALog(@"Json parsing error"); return NO; } diff --git a/Sources/Backup/LocalBackup/OAExportAsyncTask.m b/Sources/Backup/LocalBackup/OAExportAsyncTask.m index eca6a065db..fb7e46b09b 100644 --- a/Sources/Backup/LocalBackup/OAExportAsyncTask.m +++ b/Sources/Backup/LocalBackup/OAExportAsyncTask.m @@ -8,6 +8,7 @@ #import "OAExportAsyncTask.h" #import "OASettingsExporter.h" +#import "OALog.h" @interface OAExportAsyncTask() @@ -54,7 +55,7 @@ - (BOOL) doInBackground [_exporter exportSettings:_filePath error:&exportError]; if (exportError) { - NSLog(@"Failed to export items to: %@ %@", _filePath, exportError); + OALog(@"Failed to export items to: %@ %@", _filePath, exportError); return NO; } return YES; diff --git a/Sources/Backup/LocalBackup/OASettingsExporter.mm b/Sources/Backup/LocalBackup/OASettingsExporter.mm index 0ddee57f71..766cdc71d3 100644 --- a/Sources/Backup/LocalBackup/OASettingsExporter.mm +++ b/Sources/Backup/LocalBackup/OASettingsExporter.mm @@ -14,6 +14,7 @@ #import "OsmAndApp.h" #import "OARootViewController.h" #import "OAExportAsyncTask.h" +#import "OALog.h" #include @@ -83,7 +84,7 @@ - (void) exportSettings:(NSString *)file error:(NSError * _Nullable *)error if (!ok) { NSString *message = [NSString stringWithFormat:@"Archive creation failed: %@", file]; - NSLog(@"%@", message); + OALog(@"%@", message); NSMutableDictionary* details = [NSMutableDictionary dictionary]; [details setValue:message forKey:NSLocalizedDescriptionKey]; *error = [NSError errorWithDomain:@"SettingsExporter" code:0 userInfo:details]; diff --git a/Sources/Backup/LocalBackup/OASettingsImporter.mm b/Sources/Backup/LocalBackup/OASettingsImporter.mm index 7c85b8a2b2..63b6bc405e 100644 --- a/Sources/Backup/LocalBackup/OASettingsImporter.mm +++ b/Sources/Backup/LocalBackup/OASettingsImporter.mm @@ -44,6 +44,7 @@ #import "OASuggestedDownloadsItem.h" #import "OAExportAsyncTask.h" #import "OAApplicationMode.h" +#import "OALog.h" #include #include @@ -98,7 +99,7 @@ - (void) importItems:(NSString *)file items:(NSArray *)items items = [self getItemsFromJson:file]; else if ([items count] == 0) { - NSLog(@"No items"); + OALog(@"No items"); return nil; } @@ -107,7 +108,7 @@ - (void) importItems:(NSString *)file items:(NSArray *)items const auto archiveItems = archive.getItems(&ok, false); if (!ok) { - NSLog(@"Error reading zip file"); + OALog(@"Error reading zip file"); return items; } @@ -146,7 +147,7 @@ - (void) importItems:(NSString *)file items:(NSArray *)items { if (!archive.extractItemToFile(archiveItem.name, QString::fromNSString([_tmpFilesDir stringByAppendingPathComponent:itemName]))) { - NSLog(@"Error processing directory item"); + OALog(@"Error processing directory item"); continue; } } @@ -156,7 +157,7 @@ - (void) importItems:(NSString *)file items:(NSArray *)items { if (!archive.extractItemToFile(archiveItem.name, QString::fromNSString(tmpFileName))) { - NSLog(@"Error processing items"); + OALog(@"Error processing items"); continue; } } @@ -184,7 +185,7 @@ - (void) importItems:(NSString *)file items:(NSArray *)items const auto archiveItems = archive.getItems(&ok, false); if (!ok) { - NSLog(@"Error reading zip file"); + OALog(@"Error reading zip file"); return items; } @@ -199,7 +200,7 @@ - (void) importItems:(NSString *)file items:(NSArray *)items if (itemsJsonData.isEmpty()) { [fileManager removeItemAtPath:_tmpFilesDir error:nil]; - NSLog(@"Error reading or empty items.json"); + OALog(@"Error reading or empty items.json"); return items; } OASettingsItemsFactory *factory = [[OASettingsItemsFactory alloc] initWithJSONData:itemsJsonData.toRawNSData()]; @@ -262,7 +263,7 @@ - (void)collectItemsFromDictioanry:(NSDictionary *)json { NSInteger version = json[@"version"] ? [json[@"version"] integerValue] : kVersion; if (version > kVersion) { - NSLog(@"Error: unsupported version"); + OALog(@"Error: unsupported version"); return; } [[OASettingsHelper sharedInstance] setCurrentBackupVersion:version]; @@ -296,7 +297,7 @@ - (void)collectItemsFromDictioanry:(NSDictionary *)json { } if ([_items count] == 0) { - NSLog(@"No items"); + OALog(@"No items"); return; } for (OASettingsItem *item in _items) @@ -323,7 +324,7 @@ - (void) collectItemsFromData:(NSData *)jsonUtf8Data NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonUtf8Data options:kNilOptions error:&jsonError]; if (jsonError) { - NSLog(@"Error reading json"); + OALog(@"Error reading json"); return; } @@ -535,7 +536,7 @@ - (void) onPreExecute @try { return [_importer collectItems:_filePath]; } @catch (NSException *exception) { - NSLog(@"Failed to collect items from: %@ %@", _filePath, exception); + OALog(@"Failed to collect items from: %@ %@", _filePath, exception); } break; case EOAImportTypeCheckDuplicates: diff --git a/Sources/Backup/LocalBackup/SettingsItems/OAGpxSettingsItem.mm b/Sources/Backup/LocalBackup/SettingsItems/OAGpxSettingsItem.mm index 04c8f97949..8f0242834f 100644 --- a/Sources/Backup/LocalBackup/SettingsItems/OAGpxSettingsItem.mm +++ b/Sources/Backup/LocalBackup/SettingsItems/OAGpxSettingsItem.mm @@ -12,6 +12,7 @@ #import "OsmAndApp.h" #import "OAGPXAppearanceCollection.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" @interface OAGpxSettingsItem() @@ -178,7 +179,7 @@ - (void)updateGpxParams } else { - NSLog(@"[ERROR] -> OAGpxSettingsItem -> gpx for self.filePath: %@ is empty", self.filePath); + OALog(@"[ERROR] -> OAGpxSettingsItem -> gpx for self.filePath: %@ is empty", self.filePath); } } diff --git a/Sources/Backup/LocalBackup/SettingsItems/OAQuickActionsSettingsItem.mm b/Sources/Backup/LocalBackup/SettingsItems/OAQuickActionsSettingsItem.mm index 2021b01081..7ba6869497 100644 --- a/Sources/Backup/LocalBackup/SettingsItems/OAQuickActionsSettingsItem.mm +++ b/Sources/Backup/LocalBackup/SettingsItems/OAQuickActionsSettingsItem.mm @@ -18,6 +18,7 @@ #import "OAShowHidePoiAction.h" #import "Localization.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" #define APPROXIMATE_QUICK_ACTION_SIZE_BYTES 135 @@ -168,7 +169,7 @@ - (void)readItemsFromJson:(id)json error:(NSError * _Nullable __autoreleasing *) } @catch (NSException *e) { - NSLog(@"Failed to read quick action items: %@", e.reason); + OALog(@"Failed to read quick action items: %@", e.reason); return; } } diff --git a/Sources/Backup/OABackupDbHelper.m b/Sources/Backup/OABackupDbHelper.m index 5fe328a3e4..10f06b6620 100644 --- a/Sources/Backup/OABackupDbHelper.m +++ b/Sources/Backup/OABackupDbHelper.m @@ -7,6 +7,7 @@ // #import "OABackupDbHelper.h" +#import "OALog.h" #import @@ -146,7 +147,7 @@ - (void) load if (sqlite3_exec(backupFilesDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); + OALog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); } if (errMsg != NULL) sqlite3_free(errMsg); @@ -154,7 +155,7 @@ - (void) load const char *create_index = [NSString stringWithFormat:@"CREATE INDEX IF NOT EXISTS %@ ON %@ (%@, %@)", UPLOADED_FILES_INDEX_TYPE_NAME, UPLOADED_FILES_TABLE_NAME, UPLOADED_FILE_COL_TYPE, UPLOADED_FILE_COL_NAME].UTF8String; if (sqlite3_exec(backupFilesDB, create_index, NULL, NULL, &idxErrMsg) != SQLITE_OK) { - NSLog(@"Failed to create index: %@", [NSString stringWithCString:idxErrMsg encoding:NSUTF8StringEncoding]); + OALog(@"Failed to create index: %@", [NSString stringWithCString:idxErrMsg encoding:NSUTF8StringEncoding]); } if (idxErrMsg != NULL) sqlite3_free(idxErrMsg); @@ -163,7 +164,7 @@ - (void) load if (sqlite3_exec(backupFilesDB, modified_sql_stmt, NULL, NULL, &modifiederrMsg) != SQLITE_OK) { - NSLog(@"Failed to create table: %@", [NSString stringWithCString:modifiederrMsg encoding:NSUTF8StringEncoding]); + OALog(@"Failed to create table: %@", [NSString stringWithCString:modifiederrMsg encoding:NSUTF8StringEncoding]); } if (modifiederrMsg != NULL) sqlite3_free(modifiederrMsg); diff --git a/Sources/Backup/OABackupHelper.mm b/Sources/Backup/OABackupHelper.mm index 3b7318e1a6..e9721f3534 100644 --- a/Sources/Backup/OABackupHelper.mm +++ b/Sources/Backup/OABackupHelper.mm @@ -34,6 +34,7 @@ #import "OABackupListeners.h" #import "OAPrepareBackupTask.h" #import "OAURLSessionProgress.h" +#import "OALog.h" #import "OsmAnd_Maps-Swift.h" #define kUpdateIdOperation @"Update order id" @@ -347,7 +348,7 @@ - (NSString *) getOrderId OASubscription *purchasedSubscription = iapHelper.getAnyPurchasedOsmAndProSubscription; if (purchasedSubscription) { - NSLog(@"Found purchased subscription: %@", [purchasedSubscription getOrderId]); + OALog(@"Found purchased subscription: %@", [purchasedSubscription getOrderId]); return [purchasedSubscription getOrderId]; } return nil; @@ -850,7 +851,7 @@ - (NSString *) uploadFile:(NSString *)fileName } else { - NSLog(@"Cannot obtain updatetime after upload. Server response: %@", [[NSString alloc] initWithData:resp encoding:NSUTF8StringEncoding]); + OALog(@"Cannot obtain updatetime after upload. Server response: %@", [[NSString alloc] initWithData:resp encoding:NSUTF8StringEncoding]); } } if (error == nil && [status isEqualToString:@"ok"]) diff --git a/Sources/Backup/OABackupImporter.m b/Sources/Backup/OABackupImporter.m index 43627b5626..0e866a8633 100644 --- a/Sources/Backup/OABackupImporter.m +++ b/Sources/Backup/OABackupImporter.m @@ -21,6 +21,7 @@ #import "OACollectionSettingsItem.h" #import "OAOperationLog.h" #import "OAAtomicInteger.h" +#import "OALog.h" #import "Localization.h" @interface OAItemFileDownloadTask : NSOperation @@ -57,7 +58,7 @@ - (void) downloadItemFile:(NSString *)tempFilePath reader:(OASettingsItemReader [reader readFromFile:tempFilePath error:&err]; [item applyAdditionalParams:tempFilePath]; if (err) - NSLog(@"Error reading downloaded item: %@", tempFilePath); + OALog(@"Error reading downloaded item: %@", tempFilePath); } @end @@ -192,7 +193,7 @@ - (OACollectItemsResult *) collectItems:(NSArray *)settingsIte } }]; } @catch (NSException *e) { - NSLog(@"Failed to collect items for backup"); + OALog(@"Failed to collect items for backup"); } [operationLog finishOperation]; if (error.length > 0) @@ -297,7 +298,7 @@ - (void) importItemFile:(OARemoteFile *)remoteFile item:(OASettingsItem *)item f @catch (NSException *exception) { [item.warnings addObject:[NSString stringWithFormat:OALocalizedString(@"settings_item_read_error"), item.name]]; - NSLog(@"Error reading item data: %@ %@", item.name, exception.reason); + OALog(@"Error reading item data: %@ %@", item.name, exception.reason); } } @@ -555,7 +556,7 @@ - (void) generateItemsJsonByDictionary:(NSMutableArray *)itemsJson if (json && ! jsonErr) [itemsJson addObject:json]; else - NSLog(@"generateItemsJson error: filePath:%@ %@", filePath, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + OALog(@"generateItemsJson error: filePath:%@ %@", filePath, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); } else { diff --git a/Sources/Backup/OAExportBackupTask.m b/Sources/Backup/OAExportBackupTask.m index d1533638b6..bd7c42b3f6 100644 --- a/Sources/Backup/OAExportBackupTask.m +++ b/Sources/Backup/OAExportBackupTask.m @@ -17,6 +17,7 @@ #import "OAPrepareBackupResult.h" #import "OARemoteFile.h" #import "OAConcurrentCollections.h" +#import "OALog.h" @interface OAExportBackupTask () @@ -92,7 +93,7 @@ - (NSString *)doInBackground } @catch (NSException *e) { - NSLog(@"Failed to backup items: %@", e.reason); + OALog(@"Failed to backup items: %@", e.reason); error = e.reason; } return error; diff --git a/Sources/Backup/OAImportBackupItemsTask.m b/Sources/Backup/OAImportBackupItemsTask.m index bc24e1150d..e85fd19dce 100644 --- a/Sources/Backup/OAImportBackupItemsTask.m +++ b/Sources/Backup/OAImportBackupItemsTask.m @@ -11,6 +11,7 @@ #import "OABackupHelper.h" #import "OAPrepareBackupResult.h" #import "OASettingsItem.h" +#import "OALog.h" @implementation OAImportBackupItemsTask { @@ -57,7 +58,7 @@ - (BOOL) doInBackground [_importer importItems:_items remoteFiles:remoteFiles forceReadData:_foreceReadData restoreDeleted:_restoreDeleted]; return YES; } @catch (NSException *exception) { - NSLog(@"Failed to import items from backup"); + OALog(@"Failed to import items from backup"); } return NO; } diff --git a/Sources/Backup/OAImportBackupTask.m b/Sources/Backup/OAImportBackupTask.m index 5332be226c..f61226b354 100644 --- a/Sources/Backup/OAImportBackupTask.m +++ b/Sources/Backup/OAImportBackupTask.m @@ -19,6 +19,7 @@ #import "OAImportBackupItemsTask.h" #import "OASettingsImporter.h" #import "OABackupInfo.h" +#import "OALog.h" @implementation OAItemProgressInfo @@ -167,7 +168,7 @@ - (void)fetchRemoteFileInfo:(OARemoteFile *)remoteFile itemsJson:(NSMutableArray if (json && !jsonErr) [itemsJson addObject:json]; else - NSLog(@"importBackupTask error: filePath:%@ %@", filePath, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + OALog(@"importBackupTask error: filePath:%@ %@", filePath, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); } else { @@ -199,7 +200,7 @@ - (void)updateFileUploadTime:(OAPrepareBackupResult *)backup backupHelper:(OABac } @catch (NSException *e) { - NSLog(@"Failed to collect items for backup: %@", e.reason); + OALog(@"Failed to collect items for backup: %@", e.reason); } return nil; } @@ -224,7 +225,7 @@ - (void)updateFileUploadTime:(OAPrepareBackupResult *)backup backupHelper:(OABac } @catch (NSException *e) { - NSLog(@"Failed to recollect items for backup import: %@", e.reason); + OALog(@"Failed to recollect items for backup import: %@", e.reason); return nil; } } diff --git a/Sources/Backup/OANetworkWriter.mm b/Sources/Backup/OANetworkWriter.mm index ee2dfbfd57..bc8cefe65f 100644 --- a/Sources/Backup/OANetworkWriter.mm +++ b/Sources/Backup/OANetworkWriter.mm @@ -13,6 +13,7 @@ #import "OASettingsItemWriter.h" #import "OAFileSettingsItem.h" #import "OrderedDictionary.h" +#import "OALog.h" #include @@ -81,7 +82,7 @@ - (void)write:(OASettingsItem *)item } if (error != nil) { - NSLog(@"OANetworkWriter error: %@", error); + OALog(@"OANetworkWriter error: %@", error); @throw [NSException exceptionWithName:@"IOException" reason:error userInfo:nil]; } } diff --git a/Sources/Backup/OAPrepareBackupTask.m b/Sources/Backup/OAPrepareBackupTask.m index 1c1677c2db..6f9cf6934a 100644 --- a/Sources/Backup/OAPrepareBackupTask.m +++ b/Sources/Backup/OAPrepareBackupTask.m @@ -12,6 +12,7 @@ #import "OAPrepareBackupResult.h" #import "OANetworkSettingsHelper.h" #import "Localization.h" +#import "OALog.h" @interface OABackupTaskType () @@ -172,7 +173,7 @@ - (void) doCollectRemoteFiles { [self onError:message]; } - NSLog(@"Collect remote files error: %@", e.reason); + OALog(@"Collect remote files error: %@", e.reason); } } diff --git a/Sources/Backup/OASyncBackupTask.mm b/Sources/Backup/OASyncBackupTask.mm index 6b17d50b9d..7c53d0e138 100644 --- a/Sources/Backup/OASyncBackupTask.mm +++ b/Sources/Backup/OASyncBackupTask.mm @@ -20,6 +20,7 @@ #import "OARemoteFile.h" #import "OsmAndApp.h" #import "OAAppSettings.h" +#import "OALog.h" #include @@ -156,7 +157,7 @@ - (void) uploadNewItems } @catch (NSException *e) { - NSLog(@"Backup generation error: %@", e.reason); + OALog(@"Backup generation error: %@", e.reason); } } diff --git a/Sources/Controllers/Cloud/OACloudAccountCreateViewController.m b/Sources/Controllers/Cloud/OACloudAccountCreateViewController.m index aac3f7e386..bea9a11afb 100644 --- a/Sources/Controllers/Cloud/OACloudAccountCreateViewController.m +++ b/Sources/Controllers/Cloud/OACloudAccountCreateViewController.m @@ -16,6 +16,7 @@ #import "OAInputTableViewCell.h" #import "OsmAnd_Maps-Swift.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" @interface OACloudAccountCreateViewController () @@ -204,7 +205,7 @@ - (void)onRegisterDevice:(NSInteger)status message:(NSString *)message error:(OA } _continuePressed = NO; [self updateScreen]; - NSLog(@"Backup error: %@", error.getLocalizedError); + OALog(@"Backup error: %@", error.getLocalizedError); } } @@ -221,7 +222,7 @@ - (void)onRegisterUser:(NSInteger)status message:(NSString *)message error:(OABa else { self.errorMessage = error != nil ? error.getLocalizedError : message; - NSLog(@"%@", message); + OALog(@"%@", message); _continuePressed = NO; [self updateScreen]; } diff --git a/Sources/Controllers/Cloud/OACloudAccountLoginViewController.m b/Sources/Controllers/Cloud/OACloudAccountLoginViewController.m index f83de0e5ee..fc7306d4a0 100644 --- a/Sources/Controllers/Cloud/OACloudAccountLoginViewController.m +++ b/Sources/Controllers/Cloud/OACloudAccountLoginViewController.m @@ -17,6 +17,7 @@ #import "OAInputTableViewCell.h" #import "OsmAnd_Maps-Swift.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" @interface OACloudAccountLoginViewController () @@ -308,7 +309,7 @@ - (void)onRegisterDevice:(NSInteger)status message:(NSString *)message error:(OA } _continuePressed = NO; [self updateScreen]; - NSLog(@"Backup error: %@", error.getLocalizedError); + OALog(@"Backup error: %@", error.getLocalizedError); } } diff --git a/Sources/Controllers/Cloud/OACloudAccountVerificationViewController.m b/Sources/Controllers/Cloud/OACloudAccountVerificationViewController.m index 65098e7f31..e9888307d1 100644 --- a/Sources/Controllers/Cloud/OACloudAccountVerificationViewController.m +++ b/Sources/Controllers/Cloud/OACloudAccountVerificationViewController.m @@ -15,6 +15,7 @@ #import "OAInputTableViewCell.h" #import "OsmAnd_Maps-Swift.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" #define VERIFICATION_CODE_EXPIRATION_TIME_MIN (10 * 60) @@ -205,7 +206,7 @@ - (void) continueButtonPressed { self.errorMessage = OALocalizedString(@"backup_error_invalid_token"); [self updateScreen]; - NSLog(@"Token is not valid"); + OALog(@"Token is not valid"); } } diff --git a/Sources/Controllers/DashboardOnMap/MapSettings/OAMapSettingsOnlineSourcesScreen.mm b/Sources/Controllers/DashboardOnMap/MapSettings/OAMapSettingsOnlineSourcesScreen.mm index b1236b9c67..18fdb41333 100644 --- a/Sources/Controllers/DashboardOnMap/MapSettings/OAMapSettingsOnlineSourcesScreen.mm +++ b/Sources/Controllers/DashboardOnMap/MapSettings/OAMapSettingsOnlineSourcesScreen.mm @@ -15,6 +15,7 @@ #import "OASimpleTableViewCell.h" #import "OAMapSource.h" #import "OAAppData.h" +#import "OALog.h" #include #include @@ -123,7 +124,7 @@ - (void) setupView } else { - NSLog(@"Failed to download online tile resources list."); + OALog(@"Failed to download online tile resources list."); } }); } diff --git a/Sources/Controllers/DashboardOnMap/MapSettings/OAWeatherLayerSettingsViewController.mm b/Sources/Controllers/DashboardOnMap/MapSettings/OAWeatherLayerSettingsViewController.mm index a2acc9bd7f..e3cde872d8 100644 --- a/Sources/Controllers/DashboardOnMap/MapSettings/OAWeatherLayerSettingsViewController.mm +++ b/Sources/Controllers/DashboardOnMap/MapSettings/OAWeatherLayerSettingsViewController.mm @@ -23,6 +23,7 @@ #import "OAAppData.h" #import "OAAutoObserverProxy.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" #import "OsmAnd_Maps-Swift.h" #import "OASwitchTableViewCell.h" @@ -334,7 +335,7 @@ - (void)generateData @"type" : kEnableDescrCell, @"title" : text }]; - NSLog([NSString stringWithFormat:@"%.1f", [OAUtilities calculateTextBounds:text width:width font:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]].height]); + OALog([NSString stringWithFormat:@"%.1f", [OAUtilities calculateTextBounds:text width:width font:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]].height]); _menuHeight += [OAUtilities calculateTextBounds:text width:width font:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]].height + kTextLineCellFixedHeight; } diff --git a/Sources/Controllers/Help/OAHelpViewController.mm b/Sources/Controllers/Help/OAHelpViewController.mm index 8f695ebc59..f8d785569f 100644 --- a/Sources/Controllers/Help/OAHelpViewController.mm +++ b/Sources/Controllers/Help/OAHelpViewController.mm @@ -17,6 +17,7 @@ #import "OsmAnd_Maps-Swift.h" #import "OAAppVersion.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" static NSString * const kLinkInternalType = @"internal_link"; static NSString * const kLinkExternalType = @"ext_link"; @@ -242,7 +243,7 @@ - (void)loadAndParseJson [_helpDataManager loadAndParseJsonFrom:kPopularArticlesAndTelegramChats for:HelperDataItemsPopularArticles completion:^(NSArray *articles, NSError *error) { if (error) { - NSLog(OALocalizedString(@"osm_failed_uploads")); + OALog(OALocalizedString(@"osm_failed_uploads")); } else if (articles) { @@ -258,7 +259,7 @@ - (void)loadAndParseJsonForSiteArticles [_helpDataManager loadAndParseJsonFrom:kPopularArticlesAndTelegramChats for:HelperDataItemsSiteArticles completion:^(NSArray *articles, NSError *error) { if (error) { - NSLog(@"Error loading articles: %@", error.localizedDescription); + OALog(@"Error loading articles: %@", error.localizedDescription); } else if (articles) { diff --git a/Sources/Controllers/Map/Layers/OAGPXLayer.mm b/Sources/Controllers/Map/Layers/OAGPXLayer.mm index 6790d4b513..0ff364f40b 100644 --- a/Sources/Controllers/Map/Layers/OAGPXLayer.mm +++ b/Sources/Controllers/Map/Layers/OAGPXLayer.mm @@ -36,6 +36,7 @@ #import "OAConcurrentCollections.h" #import "OsmAnd_Maps-Swift.h" #import "OsmAndSharedWrapper.h" +#import "OALog.h" #include #include @@ -532,7 +533,7 @@ - (void) refreshGpxTracks } else { - NSLog(@"Track not found or index is out of bounds"); + OALog(@"Track not found or index is out of bounds"); } } segStartIndex += seg.points.count; diff --git a/Sources/Controllers/Map/Layers/OAPreviewRouteLineLayer.mm b/Sources/Controllers/Map/Layers/OAPreviewRouteLineLayer.mm index e4dd1ece86..a70a83112b 100644 --- a/Sources/Controllers/Map/Layers/OAPreviewRouteLineLayer.mm +++ b/Sources/Controllers/Map/Layers/OAPreviewRouteLineLayer.mm @@ -25,6 +25,7 @@ #import "OAAppData.h" #import "OAApplicationMode.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" #include #include @@ -585,7 +586,7 @@ - (void) fillPreviewLineArrays:(QVector &)points distances:(NSMu BOOL success = [self fillRouteInfoAttributeArrays:points distances:distances angles:angles colors:colors]; if (!success) { - NSLog(@"Failed to draw attribute coloring for appearance"); + OALog(@"Failed to draw attribute coloring for appearance"); _colorizationScheme = COLORIZATION_NONE; } } diff --git a/Sources/Controllers/Map/OAMapViewController.mm b/Sources/Controllers/Map/OAMapViewController.mm index 991ff983cb..591d4682c5 100644 --- a/Sources/Controllers/Map/OAMapViewController.mm +++ b/Sources/Controllers/Map/OAMapViewController.mm @@ -2319,7 +2319,7 @@ - (void) updateCurrentMapSource _obfMapObjectsProvider.reset(new OsmAnd::ObfMapObjectsProvider(_app.resourcesManager->obfsCollection)); - NSLog(@"%@", [OAUtilities currentLang]); + OALog(@"%@", [OAUtilities currentLang]); OsmAnd::MapPresentationEnvironment::LanguagePreference langPreferences = OsmAnd::MapPresentationEnvironment::LanguagePreference::NativeOnly; @@ -2478,7 +2478,7 @@ - (void) updateCurrentMapSource _obfMapObjectsProvider.reset(new OsmAnd::ObfMapObjectsProvider(_app.resourcesManager->obfsCollection)); - NSLog(@"%@", [OAUtilities currentLang]); + OALog(@"%@", [OAUtilities currentLang]); OsmAnd::MapPresentationEnvironment::LanguagePreference langPreferences = OsmAnd::MapPresentationEnvironment::LanguagePreference::NativeOnly; @@ -3573,9 +3573,9 @@ - (BOOL)updateMetadata:(OASMetadata *)metadata oldPath:(NSString *)oldPath docPa gpxFile.author = [OAAppVersion getFullVersionWithAppName]; OASKException *exception = [OASGpxUtilities.shared writeGpxFileFile:file gpxFile:gpxFile]; if (!exception) { - NSLog(@"writeGpxFileFile is true"); + OALog(@"writeGpxFileFile is true"); } else { - NSLog(@"writeGpxFileFile is false"); + OALog(@"writeGpxFileFile is false"); } return YES; diff --git a/Sources/Controllers/Map/Widgets/OABaseWidgetView.m b/Sources/Controllers/Map/Widgets/OABaseWidgetView.m index 3891212e25..2aa062aad1 100644 --- a/Sources/Controllers/Map/Widgets/OABaseWidgetView.m +++ b/Sources/Controllers/Map/Widgets/OABaseWidgetView.m @@ -10,6 +10,7 @@ #import "OAMapInfoController.h" #import "OsmAnd_Maps-Swift.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" @implementation OABaseWidgetView { @@ -186,7 +187,7 @@ - (BOOL)isTextInfo - (void)updateSimpleLayout { - NSLog(@"call base updateSimpleLayout"); + OALog(@"call base updateSimpleLayout"); } - (void)showBottomSeparator:(BOOL)show diff --git a/Sources/Controllers/Map/Widgets/OADestinationsLineWidget.mm b/Sources/Controllers/Map/Widgets/OADestinationsLineWidget.mm index 01c4f7e0ec..6c1713ee8f 100644 --- a/Sources/Controllers/Map/Widgets/OADestinationsLineWidget.mm +++ b/Sources/Controllers/Map/Widgets/OADestinationsLineWidget.mm @@ -20,6 +20,7 @@ #import "OAMapLayers.h" #import "OAColors.h" #import "OAOsmAndFormatter.h" +#import "OALog.h" #include @@ -297,7 +298,7 @@ - (void) drawArrow:(OADestination *)marker inContext:(CGContextRef)ctx } else { - NSLog(@"Faliled to create OADestinationsLineWidget image for colorName: %@", colorName); + OALog(@"Faliled to create OADestinationsLineWidget image for colorName: %@", colorName); } } CGContextRestoreGState(ctx); diff --git a/Sources/Controllers/MyPlaces/TracksViewController.swift b/Sources/Controllers/MyPlaces/TracksViewController.swift index b62b88052c..800d222686 100644 --- a/Sources/Controllers/MyPlaces/TracksViewController.swift +++ b/Sources/Controllers/MyPlaces/TracksViewController.swift @@ -1318,7 +1318,7 @@ final class TracksViewController: OACompoundViewController, UITableViewDelegate, updateAllFoldersVCData(forceLoad: true) } } else { - NSLog("renameFolder -> parentFile is empty") + OALog("renameFolder -> parentFile is empty") } } else { showErrorAlert(localizedString("folder_already_exsists")) diff --git a/Sources/Controllers/OsmEditing/OAOpeningHoursSelectionViewController.mm b/Sources/Controllers/OsmEditing/OAOpeningHoursSelectionViewController.mm index 730097c03a..1940bb7bb7 100644 --- a/Sources/Controllers/OsmEditing/OAOpeningHoursSelectionViewController.mm +++ b/Sources/Controllers/OsmEditing/OAOpeningHoursSelectionViewController.mm @@ -17,6 +17,7 @@ #import "OAOSMSettings.h" #import "OsmAnd_Maps-Swift.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" #include @@ -275,7 +276,7 @@ -(void)timePickerChanged:(id)sender -(void)updateRuleTime { const auto rule = std::dynamic_pointer_cast(_currentRule); - NSLog(@"startMinutes: %d", [self dateToMinutes:_startDate]); + OALog(@"startMinutes: %d", [self dateToMinutes:_startDate]); rule->setStartTime([self dateToMinutes:_startDate]); rule->setEndTime([self dateToMinutes:_endDate]); } diff --git a/Sources/Controllers/OsmEditing/OAOsmEditingViewController.mm b/Sources/Controllers/OsmEditing/OAOsmEditingViewController.mm index c3eb855e2b..b6ead0c516 100644 --- a/Sources/Controllers/OsmEditing/OAOsmEditingViewController.mm +++ b/Sources/Controllers/OsmEditing/OAOsmEditingViewController.mm @@ -32,6 +32,7 @@ #import "OsmAnd_Maps-Swift.h" #import "GeneratedAssetSymbols.h" #import "OAPluginsHelper.h" +#import "OALog.h" #import @@ -120,7 +121,7 @@ +(void)commitEntity:(EOAAction)action { if (!info && CREATE != action && [util isKindOfClass:OAOpenStreetMapRemoteUtil.class]) { - NSLog(@"Entity info was not loaded"); + OALog(@"Entity info was not loaded"); return; } dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ diff --git a/Sources/Controllers/Panels/OAMapPanelViewController.mm b/Sources/Controllers/Panels/OAMapPanelViewController.mm index 3e4f5298e6..74f430177b 100644 --- a/Sources/Controllers/Panels/OAMapPanelViewController.mm +++ b/Sources/Controllers/Panels/OAMapPanelViewController.mm @@ -2210,7 +2210,7 @@ - (void) targetGoToGPX } else { - NSLog(@"targetGoToGPX wrong cast"); + OALog(@"targetGoToGPX wrong cast"); } } else @@ -4088,7 +4088,6 @@ - (void) startProgress - (void) updateProgress:(int)progress { - //NSLog(@"Route calculation in progress: %d", progress); dispatch_async(dispatch_get_main_queue(), ^{ [self.hudViewController onRoutingProgressChanged:progress]; }); @@ -4096,7 +4095,7 @@ - (void) updateProgress:(int)progress - (void) finish { - NSLog(@"Route calculation finished"); + OALog(@"Route calculation finished"); dispatch_async(dispatch_get_main_queue(), ^{ [self.hudViewController onRoutingProgressFinished]; }); diff --git a/Sources/Controllers/Resources/OADonationSettingsViewController.mm b/Sources/Controllers/Resources/OADonationSettingsViewController.mm index 4a8150dde0..cb95122f2d 100644 --- a/Sources/Controllers/Resources/OADonationSettingsViewController.mm +++ b/Sources/Controllers/Resources/OADonationSettingsViewController.mm @@ -19,6 +19,7 @@ #import "OAWorldRegion.h" #import "OAIAPHelper.h" #import "OANetworkUtilities.h" +#import "OALog.h" #import #include @@ -564,7 +565,7 @@ - (void)onBottomButtonPressed if (![map objectForKey:@"error"]) { NSString *userId = [map objectForKey:@"userid"]; - NSLog(@"UserId = %@", userId); + OALog(@"UserId = %@", userId); if (userId.length > 0) { [_settings.billingUserId set:userId]; diff --git a/Sources/Controllers/RouteInfoMenu/OARouteInfoView.mm b/Sources/Controllers/RouteInfoMenu/OARouteInfoView.mm index 931c6fa194..3b2e9bfae4 100644 --- a/Sources/Controllers/RouteInfoMenu/OARouteInfoView.mm +++ b/Sources/Controllers/RouteInfoMenu/OARouteInfoView.mm @@ -68,6 +68,7 @@ #import "OARequiredMapsResourceViewController.h" #import "OAResourcesUIHelper.h" #import "OsmAndSharedWrapper.h" +#import "OALog.h" #include @@ -1996,7 +1997,7 @@ - (void)showRequiredMapsResourceViewController } else { - NSLog(@"showRequiredMapsResourceViewController _missingMaps or _mapsToUpdate is empty"); + OALog(@"showRequiredMapsResourceViewController _missingMaps or _mapsToUpdate is empty"); } } diff --git a/Sources/Controllers/RoutePlanning/OARoutePlanningHudViewController.mm b/Sources/Controllers/RoutePlanning/OARoutePlanningHudViewController.mm index ab83f59c11..8a6706e897 100644 --- a/Sources/Controllers/RoutePlanning/OARoutePlanningHudViewController.mm +++ b/Sources/Controllers/RoutePlanning/OARoutePlanningHudViewController.mm @@ -58,6 +58,7 @@ #import "OsmAnd_Maps-Swift.h" #import "GeneratedAssetSymbols.h" #import "OsmAndSharedWrapper.h" +#import "OALog.h" #define kHeaderSectionHeigh 60.0 @@ -835,12 +836,12 @@ - (void) startTrackNavigation } else { - NSLog(@"An error occured while saving route planning track for navigation"); + OALog(@"An error occured while saving route planning track for navigation"); } } else { - NSLog(@"An error occured while saving route planning track for navigation: no route to save"); + OALog(@"An error occured while saving route planning track for navigation: no route to save"); } } @@ -1748,7 +1749,7 @@ - (void) addToTrackSelected if (_editingContext.getPointsCount > 0) [self showAddToTrackDialog]; // else -// NSLog(@"No points to add"); +// OALog(@"No points to add"); // Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show(); } @@ -1850,7 +1851,7 @@ - (void) reverseRouteSelected } else { - NSLog(@"Can't reverse one point"); + OALog(@"Can't reverse one point"); } } diff --git a/Sources/Controllers/Settings/ImportExport/OAImportDuplicatesViewController.mm b/Sources/Controllers/Settings/ImportExport/OAImportDuplicatesViewController.mm index 39c81ec119..bd7c80ae4d 100644 --- a/Sources/Controllers/Settings/ImportExport/OAImportDuplicatesViewController.mm +++ b/Sources/Controllers/Settings/ImportExport/OAImportDuplicatesViewController.mm @@ -35,6 +35,7 @@ #import "OAPOIHelper.h" #import "OASizes.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" @interface OAHeaderType : NSObject @@ -232,7 +233,7 @@ - (void)generateData } catch (NSException *e) { routingProfile = [routingProfileValue capitalizedString]; - NSLog(@"Error trying to get routing resource for %@ \n %@ %@", routingProfileValue, e.name, e.reason); + OALog(@"Error trying to get routing resource for %@ \n %@ %@", routingProfileValue, e.name, e.reason); } } if (routingProfile.length == 0) diff --git a/Sources/Controllers/Settings/OSMEditing/OAMappersViewController.m b/Sources/Controllers/Settings/OSMEditing/OAMappersViewController.m index 671cfdbf2b..31622ef1be 100644 --- a/Sources/Controllers/Settings/OSMEditing/OAMappersViewController.m +++ b/Sources/Controllers/Settings/OSMEditing/OAMappersViewController.m @@ -16,6 +16,7 @@ #import "Localization.h" #import #import "GeneratedAssetSymbols.h" +#import "OALog.h" #define USER_CHANGES_URL @"https://osmand.net/changesets/user-changes" #define CONTRIBUTIONS_URL @"https://www.openstreetmap.org/user/" @@ -381,7 +382,7 @@ - (void)downloadChangesInfo } @catch (NSException *e) { - NSLog(e.reason); + OALog(e.reason); } } } diff --git a/Sources/Controllers/Settings/OSMEditing/OAOsmUploadGPXVisibilityViewConroller.m b/Sources/Controllers/Settings/OSMEditing/OAOsmUploadGPXVisibilityViewConroller.m index e881e4f601..6b204c51c3 100644 --- a/Sources/Controllers/Settings/OSMEditing/OAOsmUploadGPXVisibilityViewConroller.m +++ b/Sources/Controllers/Settings/OSMEditing/OAOsmUploadGPXVisibilityViewConroller.m @@ -14,6 +14,7 @@ #import "Localization.h" #import "OsmAnd_Maps-Swift.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" @implementation OAOsmUploadGPXVisibilityViewConroller { @@ -173,7 +174,7 @@ - (void)onRowSelected:(NSIndexPath *)indexPath - (void) onVisibilityChanged:(EOAOsmUploadGPXVisibility)visibility { - NSLog(@"onVisibilityChanged"); + OALog(@"onVisibilityChanged"); _selectedVisibility = visibility; [self generateData]; [self.tableView reloadData]; diff --git a/Sources/Controllers/TargetMenu/GPX/TrackMenu/OATrackMenuHudViewController.mm b/Sources/Controllers/TargetMenu/GPX/TrackMenu/OATrackMenuHudViewController.mm index 72baf8ec01..aceefd745b 100644 --- a/Sources/Controllers/TargetMenu/GPX/TrackMenu/OATrackMenuHudViewController.mm +++ b/Sources/Controllers/TargetMenu/GPX/TrackMenu/OATrackMenuHudViewController.mm @@ -69,6 +69,7 @@ #import "OsmAnd_Maps-Swift.h" #import #import "OsmAndSharedWrapper.h" +#import "OALog.h" #define kGpxDescriptionImageHeight 149 #define kOverviewTabIndex @0 @@ -1597,7 +1598,7 @@ - (void)saveNetworkRoute gpx = [gpxDb addGPXFileToDBIfNeeded:path]; if (!gpx) { - NSLog(@"[ERROR] saveNetworkRoute"); + OALog(@"[ERROR] saveNetworkRoute"); return; } OASGpxTrackAnalysis *analysis = [gpx getAnalysis]; diff --git a/Sources/Controllers/TargetMenu/Routing/OARouteDetailsGraphViewController.mm b/Sources/Controllers/TargetMenu/Routing/OARouteDetailsGraphViewController.mm index 908e4cc1d9..18a7f0f512 100644 --- a/Sources/Controllers/TargetMenu/Routing/OARouteDetailsGraphViewController.mm +++ b/Sources/Controllers/TargetMenu/Routing/OARouteDetailsGraphViewController.mm @@ -29,6 +29,7 @@ #import "OARouteStatisticsModeCell.h" #import "OAStatisticsSelectionBottomSheetViewController.h" #import "OAGPXDatabase.h" +#import "OALog.h" #import "GeneratedAssetSymbols.h" #import @@ -438,7 +439,7 @@ - (void)cancelPressed } else { - NSLog(@"trackItem is empty"); + OALog(@"trackItem is empty"); } }]; } diff --git a/Sources/Controllers/TravelGuides/data/OATravelGuidesHelper.mm b/Sources/Controllers/TravelGuides/data/OATravelGuidesHelper.mm index 9825f60060..5b486cfd59 100644 --- a/Sources/Controllers/TravelGuides/data/OATravelGuidesHelper.mm +++ b/Sources/Controllers/TravelGuides/data/OATravelGuidesHelper.mm @@ -26,6 +26,7 @@ #import "OAMapLayers.h" #import "OARootViewController.h" #import "OAMapPanelViewController.h" +#import "OALog.h" #import "OAMapViewController.h" #import "OsmAnd_Maps-Swift.h" #import "OAAppVersion.h" @@ -232,7 +233,7 @@ + (NSString *) createGpxFile:(OATravelArticle *)article fileName:(NSString *)fil } } } else { - NSLog(@"[ERROR] -> save gpx"); + OALog(@"[ERROR] -> save gpx"); } return filePath; diff --git a/Sources/Controllers/TravelGuides/data/OATravelLocalDataDbHelper.mm b/Sources/Controllers/TravelGuides/data/OATravelLocalDataDbHelper.mm index 850d6a5a08..fc92a39fe1 100644 --- a/Sources/Controllers/TravelGuides/data/OATravelLocalDataDbHelper.mm +++ b/Sources/Controllers/TravelGuides/data/OATravelLocalDataDbHelper.mm @@ -11,6 +11,7 @@ #import "OsmAnd_Maps-Swift.h" #import #import "OsmAndSharedWrapper.h" +#import "OALog.h" #include #include @@ -85,7 +86,7 @@ - (void)onGpxFileReadWithGpxFile:(OAGPXDocumentAdapter * _Nullable)gpxFile artic NSError *error; [NSFileManager.defaultManager copyItemAtPath:gpxPath toPath:tmpFilePath error:&error]; if (error) - NSLog(@"Error copying file: %@ to %@ - %@", gpxPath, tmpFilePath, [error localizedDescription]); + OALog(@"Error copying file: %@ to %@ - %@", gpxPath, tmpFilePath, [error localizedDescription]); } OsmAnd::ArchiveWriter archiveWriter; @@ -317,14 +318,14 @@ - (void) onCreate char *errMsg; if (sqlite3_exec(_dbInstance, [[self.class HISTORY_TABLE_CREATE] UTF8String], NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); + OALog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); } if (errMsg != NULL) sqlite3_free(errMsg); //create empty Bookmarks table if (sqlite3_exec(_dbInstance, [[self.class BOOKMARKS_TABLE_CREATE] UTF8String], NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); + OALog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); } if (errMsg != NULL) sqlite3_free(errMsg); @@ -332,7 +333,7 @@ - (void) onCreate const char *sql_stmt = [[NSString stringWithFormat:@"CREATE TABLE IF NOT EXISTS %@ (%@ integer)", VERSION_TABLE_NAME, VERSION_COL] UTF8String]; if (sqlite3_exec(_dbInstance, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); + OALog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); } if (errMsg != NULL) sqlite3_free(errMsg); @@ -356,7 +357,7 @@ - (void) onUpgrade:(int)dbVersion char *errMsg; if (sqlite3_exec(_dbInstance, [[NSString stringWithFormat:@"ALTER TABLE %@ ADD %@ TEXT", HISTORY_TABLE_NAME, HISTORY_COL_IMAGE_TITLE] UTF8String], NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to migrate to 9 version Travel Guides table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); + OALog(@"Failed to migrate to 9 version Travel Guides table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); isError = YES; } if (errMsg != NULL) sqlite3_free(errMsg); diff --git a/Sources/Data/OAMapStyleSettings.mm b/Sources/Data/OAMapStyleSettings.mm index fe2445b7db..4c706029f1 100644 --- a/Sources/Data/OAMapStyleSettings.mm +++ b/Sources/Data/OAMapStyleSettings.mm @@ -13,6 +13,7 @@ #import "OAMapSource.h" #import "OAAppData.h" #import "OAObservable.h" +#import "OALog.h" #include #include @@ -155,8 +156,6 @@ - (void)buildParameters:(NSString *)styleName { NSString *name = resolvedMapStyle->getStringById(p->getNameId()).toNSString(); - //NSLog(@"name = %@ title = %@ decs = %@ category = %@", name, p->getTitle().toNSString(), p->getDescription().toNSString(), p->getCategory().toNSString()); - if ([name isEqualToString:@"appMode"] || [name isEqualToString:@"baseAppMode"] || [name isEqualToString:@"engine_v1"]) diff --git a/Sources/DownloadsManager/OADownloadTask_AFURLSessionManager.m b/Sources/DownloadsManager/OADownloadTask_AFURLSessionManager.m index 8261d7b00b..ba356e5c55 100644 --- a/Sources/DownloadsManager/OADownloadTask_AFURLSessionManager.m +++ b/Sources/DownloadsManager/OADownloadTask_AFURLSessionManager.m @@ -169,7 +169,7 @@ - (void)onCompletedWith:(NSURLResponse*)response andStoredAt:(NSURL*)targetPath withError:(NSError*)error { - //NSLog(@"onCompletedWith response=%@ targetPath=%@ error=%d (%@)", response, targetPath, error.code, error.description); + //OALog(@"onCompletedWith response=%@ targetPath=%@ error=%d (%@)", response, targetPath, error.code, error.description); [_owner notifyTaskDeactivated:self]; diff --git a/Sources/DownloadsManager/OADownloadsManager.m b/Sources/DownloadsManager/OADownloadsManager.m index 98d8feb660..3469c5bd97 100644 --- a/Sources/DownloadsManager/OADownloadsManager.m +++ b/Sources/DownloadsManager/OADownloadsManager.m @@ -145,7 +145,7 @@ - (BOOL)hasActiveDownloadTasks - (void)cancelDownloadTasks { - NSLog(@"Cancel all download tasks"); + OALog(@"Cancel all download tasks"); @synchronized(_tasksSync) { [_tasks enumerateKeysAndObjectsUsingBlock:^(id key_, id obj_, BOOL *stop) { @@ -158,7 +158,7 @@ - (void)cancelDownloadTasks - (void)pauseDownloadTasks { - NSLog(@"Suspend all download tasks"); + OALog(@"Suspend all download tasks"); @synchronized(_tasksSync) { [_tasks enumerateKeysAndObjectsUsingBlock:^(id key_, id obj_, BOOL *stop) { @@ -490,13 +490,13 @@ - (NSUInteger)numberOfActiveDownloadTasksWithKeyPrefix:(NSString*)prefix // Start background task if not started yet if (_backgroundDownloadTask == UIBackgroundTaskInvalid) { - NSLog(@"Begin background download task"); + OALog(@"Begin background download task"); _backgroundDownloadTask = [[UIApplication sharedApplication] beginBackgroundTaskWithName:@"DownloadManagerBackgroundTask" expirationHandler:^{ - NSLog(@"Background download expired"); + OALog(@"Background download expired"); [self pauseDownloadTasks]; if (_backgroundDownloadTask != UIBackgroundTaskInvalid) { - NSLog(@"End background download task (time expired)"); + OALog(@"End background download task (time expired)"); [[UIApplication sharedApplication] endBackgroundTask:_backgroundDownloadTask]; _backgroundDownloadTask = UIBackgroundTaskInvalid; @@ -561,7 +561,7 @@ - (void)removeTask:(id)task // When the all task are done, end the background task if (_tasks.count == 0 && _backgroundDownloadTask != UIBackgroundTaskInvalid) { - NSLog(@"End background download task (all downloads complete"); + OALog(@"End background download task (all downloads complete"); [[UIApplication sharedApplication] endBackgroundTask:_backgroundDownloadTask]; _backgroundDownloadTask = UIBackgroundTaskInvalid; } diff --git a/Sources/FirstUsage/OAFirstUsageWizardController.mm b/Sources/FirstUsage/OAFirstUsageWizardController.mm index ffacd03e91..6bff045029 100644 --- a/Sources/FirstUsage/OAFirstUsageWizardController.mm +++ b/Sources/FirstUsage/OAFirstUsageWizardController.mm @@ -30,6 +30,7 @@ #import "OAUtilities.h" #import "OAAppVersion.h" #import "OAResourcesUISwiftHelper.h" +#import "OALog.h" #include #include @@ -405,7 +406,7 @@ - (IBAction)userLocationButtonPress:(id)sender if (!isDownloading) [self configureSearchLocationState]; else - NSLog(@"resource: %@ is downloading", resourceId); + OALog(@"resource: %@ is downloading", resourceId); } else { diff --git a/Sources/GPX/OAGPXDatabase.mm b/Sources/GPX/OAGPXDatabase.mm index 9d68c7fd68..903210a79b 100644 --- a/Sources/GPX/OAGPXDatabase.mm +++ b/Sources/GPX/OAGPXDatabase.mm @@ -19,6 +19,7 @@ #import "OAAppData.h" #import "OASharedUtil.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" #define kDbName @"gpx.db" #define GPX_EXT @"gpx" @@ -274,26 +275,26 @@ - (OASGpxDataItem *)addGPXFileToDBIfNeeded:(NSString *)filePath BOOL success = [[OASGpxDbHelper shared] addItem:dataItem]; NSString *status = success ? @"SUCCESS" : @"ERROR"; - NSLog(@"[%@] added to db | %@", status, dataItem.file.path); + OALog(@"[%@] added to db | %@", status, dataItem.file.path); // app.getSmartFolderHelper().addTrackItemToSmartFolder(new TrackItem(SharedUtil.kFile(file))); return dataItem; } else { - NSLog(@"[ERROR] loadGpxFileFile: %@ | %@", file.path, gpxFile.error.message); + OALog(@"[ERROR] loadGpxFileFile: %@ | %@", file.path, gpxFile.error.message); } } else { - NSLog(@"[INFO] file: %@ | already exist", file.path); + OALog(@"[INFO] file: %@ | already exist", file.path); } return nil; } - (void)save { - NSLog(@"[WARNING] is empty save"); + OALog(@"[WARNING] is empty save"); } @end diff --git a/Sources/GPX/OAXmlStreamWriter.mm b/Sources/GPX/OAXmlStreamWriter.mm index 273f83b47b..97ac94e8c8 100644 --- a/Sources/GPX/OAXmlStreamWriter.mm +++ b/Sources/GPX/OAXmlStreamWriter.mm @@ -7,6 +7,7 @@ // #import "OAXmlStreamWriter.h" +#import "OALog.h" #include #include #include @@ -210,7 +211,7 @@ - (BOOL)flushAndReturnError:(NSError * _Nullable * _Nullable)error __attribute__ maxLength:length - totalBytesWritten error:nil]; if (bytesWritten == -1) { - NSLog(@"Error writing to output stream"); + OALog(@"Error writing to output stream"); break; } totalBytesWritten += bytesWritten; @@ -229,7 +230,7 @@ - (BOOL)flushAndReturnError:(NSError * _Nullable * _Nullable)error __attribute__ } else { - NSLog(@"Could not write all data to output stream"); + OALog(@"Could not write all data to output stream"); return NO; } } diff --git a/Sources/Helpers/MissingMapsCalculator/MissingMapsCalculator.mm b/Sources/Helpers/MissingMapsCalculator/MissingMapsCalculator.mm index 0c2f522a5b..edc5676190 100644 --- a/Sources/Helpers/MissingMapsCalculator/MissingMapsCalculator.mm +++ b/Sources/Helpers/MissingMapsCalculator/MissingMapsCalculator.mm @@ -12,6 +12,7 @@ #import "OARoutingHelper.h" #import "OARouteProvider.h" #import "OAWorldRegion.h" +#import "OALog.h" #include #include @@ -225,7 +226,7 @@ - (BOOL)checkIfThereAreMissingMaps:(std::shared_ptr)ctx self.mapsToUpdate = [self convert:[mapsToUpdate copy]]; self.potentiallyUsedMaps = [self convert:[usedMaps copy]]; - NSLog(@"Check missing maps %lu points %.2f sec", [pointsToCheck count], ([NSDate timeIntervalSinceReferenceDate] - tm)); + OALog(@"Check missing maps %lu points %.2f sec", [pointsToCheck count], ([NSDate timeIntervalSinceReferenceDate] - tm)); return YES; } diff --git a/Sources/Helpers/OADayNightHelper.m b/Sources/Helpers/OADayNightHelper.m index 6f27699a0f..cbba58904f 100644 --- a/Sources/Helpers/OADayNightHelper.m +++ b/Sources/Helpers/OADayNightHelper.m @@ -13,6 +13,7 @@ #import "SunriseSunset.h" #import "OALocationServices.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" @implementation OADayNightHelper { @@ -99,7 +100,7 @@ - (BOOL)isNightMode if (_lastNightMode != nightMode) { _lastNightMode = nightMode; - NSLog(@"Sunrise/sunset setting to day: %@", nightMode ? @"NO" : @"YES"); + OALog(@"Sunrise/sunset setting to day: %@", nightMode ? @"NO" : @"YES"); if (!_firstCall) [[[OsmAndApp instance] dayNightModeObservable] notifyEvent]; } diff --git a/Sources/Helpers/OAFavoritesHelper.mm b/Sources/Helpers/OAFavoritesHelper.mm index 1e22314d9e..f5bb68065f 100644 --- a/Sources/Helpers/OAFavoritesHelper.mm +++ b/Sources/Helpers/OAFavoritesHelper.mm @@ -25,6 +25,7 @@ #import "OAFavoritesSettingsItem.h" #import "OAPluginsHelper.h" #import "OsmAndSharedWrapper.h" +#import "OALog.h" #import #import "OsmAnd_Maps-Swift.h" @@ -64,7 +65,7 @@ + (void)initFavorites NSError *error = nil; [[NSFileManager defaultManager] moveItemAtPath:oldfFavoritesFilename toPath:favoritesLegacyFilename error:&error]; if (error) - NSLog(@"Error moving file: %@ to %@ - %@", oldfFavoritesFilename, favoritesLegacyFilename, [error localizedDescription]); + OALog(@"Error moving file: %@ to %@ - %@", oldfFavoritesFilename, favoritesLegacyFilename, [error localizedDescription]); } // Move legacy favorites backup folder to new location @@ -74,7 +75,7 @@ + (void)initFavorites NSError *error = nil; [[NSFileManager defaultManager] moveItemAtPath:oldFavoritesBackupPath toPath:app.favoritesBackupPath error:&error]; if (error) - NSLog(@"Error moving dir: %@ to %@ - %@", oldFavoritesBackupPath, app.favoritesBackupPath, [error localizedDescription]); + OALog(@"Error moving dir: %@ to %@ - %@", oldFavoritesBackupPath, app.favoritesBackupPath, [error localizedDescription]); } BOOL legacyFavoritesExists = [[NSFileManager defaultManager] fileExistsAtPath:favoritesLegacyFilename]; @@ -708,7 +709,7 @@ + (void) backup:(NSString *)backupFileName archiveWriter.createArchive(&ok, backupFile, filesList, basePath); } if (!ok) - NSLog(@"ERROR: Favorites backup failed"); + OALog(@"ERROR: Favorites backup failed"); [self.class clearOldBackups:[self.class getBackupFiles] maxCount:BACKUP_MAX_COUNT]; } @@ -1080,7 +1081,7 @@ + (void) removeParkingReminderFromCalendar EKEvent *event = [eventStore eventWithIdentifier:plugin.getEventIdentifier]; NSError *error; if (![eventStore removeEvent:event span:EKSpanFutureEvents error:&error]) - NSLog(@"%@", [error localizedDescription]); + OALog(@"%@", [error localizedDescription]); else [plugin setEventIdentifier:nil]; } diff --git a/Sources/Helpers/OAGPXImportUIHelper.mm b/Sources/Helpers/OAGPXImportUIHelper.mm index 6ec12ebafe..c49804a8f3 100644 --- a/Sources/Helpers/OAGPXImportUIHelper.mm +++ b/Sources/Helpers/OAGPXImportUIHelper.mm @@ -14,6 +14,7 @@ #import "OAKml2Gpx.h" #import "OAIndexConstants.h" #import "Localization.h" +#import "OALog.h" #import "OAGPXAppearanceCollection.h" #import #import @@ -264,7 +265,7 @@ - (void) handleKmlImport:(NSData *)data { [gpxStr writeToFile:finalFilePath atomically:YES encoding:NSUTF8StringEncoding error:&err]; if (err) - NSLog(@"Error creating gpx file"); + OALog(@"Error creating gpx file"); [OAUtilities denyAccessToFile:_importUrl.path removeFromInbox:YES]; @@ -433,7 +434,7 @@ - (void) removeFromDB [[OAGPXDatabase sharedDb] removeGpxItem:item withLocalRemove:YES]; } else { - NSLog(@"[OAGPXImportUIHelper] -> [ERROR] -> removeFromDB"); + OALog(@"[OAGPXImportUIHelper] -> [ERROR] -> removeFromDB"); } } diff --git a/Sources/Helpers/OAGPXUIHelper.mm b/Sources/Helpers/OAGPXUIHelper.mm index d357e1427e..f0228c7fc9 100644 --- a/Sources/Helpers/OAGPXUIHelper.mm +++ b/Sources/Helpers/OAGPXUIHelper.mm @@ -26,6 +26,7 @@ #import "OASavingTrackHelper.h" #import "OsmAnd_Maps-Swift.h" #import "OAAppVersion.h" +#import "OALog.h" #include @@ -559,7 +560,7 @@ - (void)copyGPXToNewFolder:(NSString *)newFolderName [[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:destinationPath error:&err]; if (err) { - NSLog(@"copyItemAtPath: %@ toPath: %@ ", sourcePath, destinationPath); + OALog(@"copyItemAtPath: %@ toPath: %@ ", sourcePath, destinationPath); return; } @@ -629,13 +630,13 @@ - (void)renameTrack:(OASGpxDataItem *)gpx BOOL renameToFileResult = [gpx.file renameToToFile:newFile]; if (!renameToFileResult) { - NSLog(@"[ERROR] -> OAGPXUIHelper -> renameToFileResult is fail"); + OALog(@"[ERROR] -> OAGPXUIHelper -> renameToFileResult is fail"); return; } BOOL renameCurrentFileResult = [[OASGpxDbHelper shared] renameCurrentFile:gpx.file newFile:newFile]; if (!renameCurrentFileResult) { - NSLog(@"[ERROR] -> OAGPXUIHelper -> renameCurrentFileResult is fail"); + OALog(@"[ERROR] -> OAGPXUIHelper -> renameCurrentFileResult is fail"); return; } @@ -690,9 +691,9 @@ - (void)renameTrack:(OASGpxDataItem *)gpx OASKFile *file = [[OASKFile alloc] initWithFilePath:newPath]; OASKException *exception = [OASGpxUtilities.shared writeGpxFileFile:file gpxFile:doc]; if (!exception) { - NSLog(@"writeGpxFileFile result is true"); + OALog(@"writeGpxFileFile result is true"); } else { - NSLog(@"writeGpxFileFile result is false"); + OALog(@"writeGpxFileFile result is false"); } } [OASelectedGPXHelper renameVisibleTrack:oldFilePath newPath:newFilePath]; diff --git a/Sources/Helpers/OAOcbfHelper.m b/Sources/Helpers/OAOcbfHelper.m index 1a394c8ec3..175aa3c726 100644 --- a/Sources/Helpers/OAOcbfHelper.m +++ b/Sources/Helpers/OAOcbfHelper.m @@ -28,7 +28,7 @@ + (void) downloadOcbfIfUpdated:(void (^)(void))completionHandler NSError *error = nil; [fileManager copyItemAtPath:cachedPathBundle toPath:cachedPathLib error:&error]; if (error) - NSLog(@"Error copying file: %@ to %@ - %@", cachedPathBundle, cachedPathLib, [error localizedDescription]); + OALog(@"Error copying file: %@ to %@ - %@", cachedPathBundle, cachedPathLib, [error localizedDescription]); } NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; @@ -63,9 +63,9 @@ + (void)downloadOcbfIfUpdated:(NSURL *)url } @catch (NSException * e) { - NSLog(@"Error parsing last modified date: %@ - %@", lastModifiedString, [e description]); + OALog(@"Error parsing last modified date: %@ - %@", lastModifiedString, [e description]); } - NSLog(@"lastModifiedServer: %@", lastModifiedServer); + OALog(@"lastModifiedServer: %@", lastModifiedServer); NSDate *lastModifiedLocal = nil; NSFileManager *fileManager = [NSFileManager defaultManager]; @@ -74,7 +74,7 @@ + (void)downloadOcbfIfUpdated:(NSURL *)url NSError *error = nil; NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:cachedPathLib error:&error]; if (error) - NSLog(@"Error reading file attributes for: %@ - %@", cachedPathLib, [error localizedDescription]); + OALog(@"Error reading file attributes for: %@ - %@", cachedPathLib, [error localizedDescription]); lastModifiedLocal = [fileAttributes fileModificationDate]; OALog(@"lastModifiedLocal : %@", lastModifiedLocal); @@ -107,7 +107,7 @@ + (void)downloadOcbfIfUpdated:(NSURL *)url OALog(@"File modification date updated"); if (error) - NSLog(@"Error setting file attributes for: %@ - %@", cachedPathLib, [error localizedDescription]); + OALog(@"Error setting file attributes for: %@ - %@", cachedPathLib, [error localizedDescription]); } } } @@ -131,13 +131,13 @@ + (BOOL) isBundledOcbfNewer NSError *error = nil; NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:cachedPathBundle error:&error]; if (error) - NSLog(@"Error reading file attributes for: %@ - %@", cachedPathBundle, [error localizedDescription]); + OALog(@"Error reading file attributes for: %@ - %@", cachedPathBundle, [error localizedDescription]); lastModifiedBundle = [fileAttributes fileModificationDate]; fileAttributes = [fileManager attributesOfItemAtPath:cachedPathLib error:&error]; if (error) - NSLog(@"Error reading file attributes for: %@ - %@", cachedPathLib, [error localizedDescription]); + OALog(@"Error reading file attributes for: %@ - %@", cachedPathLib, [error localizedDescription]); lastModifiedLocal = [fileAttributes fileModificationDate]; diff --git a/Sources/Helpers/OAOperationLog.m b/Sources/Helpers/OAOperationLog.m index e169bc9981..544c047553 100644 --- a/Sources/Helpers/OAOperationLog.m +++ b/Sources/Helpers/OAOperationLog.m @@ -7,6 +7,7 @@ // #import "OAOperationLog.h" +#import "OALog.h" @implementation OAOperationLog { @@ -92,14 +93,14 @@ - (void) log:(NSString *)message forceLog:(BOOL)forceLog { if (_debug || forceLog) { - NSLog(@"%@", [NSString stringWithFormat:@"%@ %@", _operationName, message.length > 0 ? message : @""]); + OALog(@"%@", [NSString stringWithFormat:@"%@ %@", _operationName, message.length > 0 ? message : @""]); } } - (void) logImpl:(NSString *)message forceLog:(BOOL)forceLog { if (_debug || forceLog) - NSLog(@"%@", message); + OALog(@"%@", message); } @end diff --git a/Sources/Helpers/OAOsmAndContextImpl.mm b/Sources/Helpers/OAOsmAndContextImpl.mm index 1c7602c777..f9dcf0416f 100644 --- a/Sources/Helpers/OAOsmAndContextImpl.mm +++ b/Sources/Helpers/OAOsmAndContextImpl.mm @@ -13,6 +13,7 @@ #import "OASelectedGpxHelper.h" #import "OAGPXUIHelper.h" #import "OAPOI.h" +#import "OALog.h" static NSString * const kGpxRecDir = @"rec"; static NSString * const kGpxImportDir = @"import"; @@ -177,10 +178,10 @@ - (NSString * _Nullable)getAssetAsStringName:(NSString *)name __attribute__((swi if (fileContents) { return fileContents; } else { - NSLog(@"Error reading file %@: %@", filePath, [error localizedDescription]); + OALog(@"Error reading file %@: %@", filePath, [error localizedDescription]); } } else { - NSLog(@"File %@ not found in the bundle", name); + OALog(@"File %@ not found in the bundle", name); } return nil; } diff --git a/Sources/Helpers/OAResourcesInstaller.mm b/Sources/Helpers/OAResourcesInstaller.mm index 385fa9ca68..f318abd62d 100644 --- a/Sources/Helpers/OAResourcesInstaller.mm +++ b/Sources/Helpers/OAResourcesInstaller.mm @@ -163,7 +163,7 @@ + (void)installObfResource:(BOOL &)failed resourceId:(NSString *)resourceId loca if (!ok) { [NSFileManager.defaultManager removeItemAtPath:localPath error:nil]; - NSLog(@"Failed to install custom obf from the archive"); + OALog(@"Failed to install custom obf from the archive"); failed = YES; } @@ -180,7 +180,7 @@ + (void)installObfResource:(BOOL &)failed resourceId:(NSString *)resourceId loca if (!obfArchiveItem.isValid()) { [NSFileManager.defaultManager removeItemAtPath:localPath error:nil]; - NSLog(@"Custom obf in the archive is not valid"); + OALog(@"Custom obf in the archive is not valid"); failed = YES; } NSString *defaultPath = [OsmAndApp.instance.documentsPath stringByAppendingPathComponent:fileName].stringByDeletingPathExtension; @@ -192,7 +192,7 @@ + (void)installObfResource:(BOOL &)failed resourceId:(NSString *)resourceId loca if (!archive.extractItemToFile(obfArchiveItem.name, pathToFile)) { [NSFileManager.defaultManager removeItemAtPath:localPath error:nil]; - NSLog(@"Failed to extract custom obf from the archive"); + OALog(@"Failed to extract custom obf from the archive"); failed = YES; } else if (hidden && [NSFileManager.defaultManager fileExistsAtPath:defaultPath]) @@ -230,7 +230,7 @@ + (BOOL) installCustomResource:(NSString *)localPath resourceId:(NSString *)reso if (!ok) { [NSFileManager.defaultManager removeItemAtPath:localPath error:nil]; - NSLog(@"Failed to install custom resource from the archive"); + OALog(@"Failed to install custom resource from the archive"); return YES; } for (const auto& archiveItem : constOf(archiveItems)) @@ -244,7 +244,7 @@ + (BOOL) installCustomResource:(NSString *)localPath resourceId:(NSString *)reso if (!targetArchiveItem.isValid()) { [NSFileManager.defaultManager removeItemAtPath:localPath error:nil]; - NSLog(@"Custom resource file in the archive is not valid"); + OALog(@"Custom resource file in the archive is not valid"); return YES; } unzippedFilePath = [localPath stringByDeletingPathExtension]; @@ -253,7 +253,7 @@ + (BOOL) installCustomResource:(NSString *)localPath resourceId:(NSString *)reso if (!archive.extractItemToFile(targetArchiveItem.name, pathToFile)) { [NSFileManager.defaultManager removeItemAtPath:localPath error:nil]; - NSLog(@"Failed to extract custom resource from the archive"); + OALog(@"Failed to extract custom resource from the archive"); return YES; } resourceId = [resourceId stringByDeletingPathExtension]; @@ -367,7 +367,7 @@ - (void) processResource:(id)task } } - //NSLog(@"found name=%@ bbox=(%f,%f)(%f,%f)", foundRegion.name, foundRegion.bboxTopLeft.latitude, foundRegion.bboxTopLeft.longitude, foundRegion.bboxBottomRight.latitude, foundRegion.bboxBottomRight.longitude); + //OALog(@"found name=%@ bbox=(%f,%f)(%f,%f)", foundRegion.name, foundRegion.bboxTopLeft.latitude, foundRegion.bboxTopLeft.longitude, foundRegion.bboxBottomRight.latitude, foundRegion.bboxBottomRight.longitude); if (foundRegion && foundRegion.superregion && resource->type == OsmAnd::ResourcesManager::ResourceType::MapRegion) { diff --git a/Sources/Helpers/OAResourcesUIHelper.mm b/Sources/Helpers/OAResourcesUIHelper.mm index a964a8fe6f..be5ff062c7 100644 --- a/Sources/Helpers/OAResourcesUIHelper.mm +++ b/Sources/Helpers/OAResourcesUIHelper.mm @@ -920,7 +920,7 @@ + (void)startBackgroundDownloadOf:(NSURL *)resourceUrl resourceId:(NSString *)re NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; - NSLog(@"%@", url); + OALog(@"%@", url); id task = [[OsmAndApp instance].downloadsManager downloadTaskWithRequest:request andKey:[@"resource:" stringByAppendingString:resourceId] @@ -1337,7 +1337,7 @@ + (void) startDownloadOfCustomItem:(OACustomResourceItem *)item NSURL *url = [NSURL URLWithString:item.downloadUrl]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; - NSLog(@"%@", url); + OALog(@"%@", url); OsmAndAppInstance app = [OsmAndApp instance]; id task = [app.downloadsManager downloadTaskWithRequest:request @@ -1630,7 +1630,7 @@ + (void)startDownloadOfItem:(OARepositoryResourceItem *)item NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; - NSLog(@"%@", url); + OALog(@"%@", url); NSString* name = [self.class titleOfResourceType:item.resourceType inRegion:item.worldRegion withRegionName:YES @@ -1666,7 +1666,7 @@ + (void)startDownloadOfItem:(OARepositoryResourceItem *)item NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; - NSLog(@"%@", url); + OALog(@"%@", url); NSString* name = [self.class titleOfResource:item.resource inRegion:item.worldRegion @@ -1734,7 +1734,7 @@ + (void) startDownloadOf:(const std::shared_ptr task = [app.downloadsManager downloadTaskWithRequest:request @@ -2350,7 +2350,7 @@ + (NSString *)formatPointString:(CLLocation *)location { + (void)onlineCalculateRequestWithRouteCalculationResult:(OARouteCalculationResult *)routeCalculationResult completion:(LocationArrayCallback)completion { - NSLog(@"onlineCalculateRequestStartPoint start"); + OALog(@"onlineCalculateRequestStartPoint start"); NSURLSession *session = [NSURLSession sharedSession]; NSString *routeUrlString = @"https://maptile.osmand.net/routing/route"; @@ -2373,10 +2373,10 @@ + (void)onlineCalculateRequestWithRouteCalculationResult:(OARouteCalculationResu NSURLRequest *request = [NSURLRequest requestWithURL:url]; NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { - NSLog(@"onlineCalculateRequestStartPoint finish"); + OALog(@"onlineCalculateRequestStartPoint finish"); if (error) { - NSLog(@"Error: %@", error); + OALog(@"Error: %@", error); if (completion) { completion(nil, [NSError errorWithDomain:@"OnlineCalculateRequestErrorDomain" code:1 userInfo:@{NSLocalizedDescriptionKey: error.localizedDescription}]); @@ -2393,7 +2393,7 @@ + (void)onlineCalculateRequestWithRouteCalculationResult:(OARouteCalculationResu { @try { - NSLog(@"Response: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + OALog(@"Response: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]; NSArray *features = json[@"features"]; NSMutableArray *locationArray = [NSMutableArray array]; @@ -2415,7 +2415,7 @@ + (void)onlineCalculateRequestWithRouteCalculationResult:(OARouteCalculationResu } } } - NSLog(@"Coordinates array: %@", locationArray); + OALog(@"Coordinates array: %@", locationArray); if (completion) { completion([locationArray copy], nil); @@ -2423,28 +2423,28 @@ + (void)onlineCalculateRequestWithRouteCalculationResult:(OARouteCalculationResu } @catch (NSException *e) { - NSLog(@"NSException: %@", e.reason); + OALog(@"NSException: %@", e.reason); if (completion) { completion(nil, [NSError errorWithDomain:@"OnlineCalculateRequestErrorDomain" code:2 userInfo:@{NSLocalizedDescriptionKey: e.reason}]); } } } else { - NSLog(@"Error: No data received"); + OALog(@"Error: No data received"); if (completion) { completion(nil, [NSError errorWithDomain:@"OnlineCalculateRequestErrorDomain" code:3 userInfo:@{NSLocalizedDescriptionKey: @"Error: No data received"}]); } } } else { - NSLog(@"Error: Unexpected HTTP status code: %ld", (long)httpResponse.statusCode); + OALog(@"Error: Unexpected HTTP status code: %ld", (long)httpResponse.statusCode); if (completion) { completion(nil, [NSError errorWithDomain:@"OnlineCalculateRequestErrorDomain" code:4 userInfo:@{NSLocalizedDescriptionKey: @"Error: Unexpected HTTP status code"}]); } } } else { - NSLog(@"Error: Unexpected response type"); + OALog(@"Error: Unexpected response type"); if (completion) { completion(nil, [NSError errorWithDomain:@"OnlineCalculateRequestErrorDomain" code:5 userInfo:@{NSLocalizedDescriptionKey: @"Error: Unexpected response type"}]); diff --git a/Sources/Helpers/OAReverseGeocoder.mm b/Sources/Helpers/OAReverseGeocoder.mm index b60c11dd16..44c3b3bacd 100644 --- a/Sources/Helpers/OAReverseGeocoder.mm +++ b/Sources/Helpers/OAReverseGeocoder.mm @@ -9,6 +9,7 @@ #import "OAReverseGeocoder.h" #import "OsmAndApp.h" #import "OAAppSettings.h" +#import "OALog.h" #include #include @@ -86,7 +87,7 @@ - (NSString *) lookupAddressAtLat:(double)lat lon:(double)lon - (void) testAddressSearch:(NSString *)query lat:(double)lat lon:(double)lon { - NSLog(@"\n--- Start search: %@ ---", query); + OALog(@"\n--- Start search: %@ ---", query); OsmAndAppInstance app = [OsmAndApp instance]; const auto& obfsCollection = app.resourcesManager->obfsCollection; @@ -121,10 +122,10 @@ - (void) testAddressSearch:(NSString *)query lat:(double)lat lon:(double)lon name = res.address->getName(lang, transliterate).toNSString(); } OsmAnd::LatLon pos = OsmAnd::Utilities::convert31ToLatLon(res.address->position31); - NSLog(@">> %@ (%f km)", name, OsmAnd::Utilities::distance(lon, lat, pos.longitude, pos.latitude) / 1000); + OALog(@">> %@ (%f km)", name, OsmAnd::Utilities::distance(lon, lat, pos.longitude, pos.latitude) / 1000); } - NSLog(@"+++ Finish search +++\n"); + OALog(@"+++ Finish search +++\n"); } @end diff --git a/Sources/Helpers/OASavingTrackHelper.mm b/Sources/Helpers/OASavingTrackHelper.mm index 015e01da3d..d619db8032 100644 --- a/Sources/Helpers/OASavingTrackHelper.mm +++ b/Sources/Helpers/OASavingTrackHelper.mm @@ -185,49 +185,49 @@ - (void)createDb const char *sql_stmt = [[NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN %@ text", POINT_NAME, POINT_COL_COLOR] UTF8String]; if (sqlite3_exec(tracksDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_COLOR, POINT_NAME, errMsg); + OALog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_COLOR, POINT_NAME, errMsg); } if (errMsg != NULL) sqlite3_free(errMsg); sql_stmt = [[NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN %@ text", POINT_NAME, POINT_COL_CATEGORY] UTF8String]; if (sqlite3_exec(tracksDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_CATEGORY, POINT_NAME, errMsg); + OALog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_CATEGORY, POINT_NAME, errMsg); } if (errMsg != NULL) sqlite3_free(errMsg); sql_stmt = [[NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN %@ text", POINT_NAME, POINT_COL_DESCRIPTION] UTF8String]; if (sqlite3_exec(tracksDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_DESCRIPTION, POINT_NAME, errMsg); + OALog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_DESCRIPTION, POINT_NAME, errMsg); } if (errMsg != NULL) sqlite3_free(errMsg); sql_stmt = [[NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN %@ text", POINT_NAME, POINT_COL_ICON] UTF8String]; if (sqlite3_exec(tracksDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_ICON, POINT_NAME, errMsg); + OALog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_ICON, POINT_NAME, errMsg); } if (errMsg != NULL) sqlite3_free(errMsg); sql_stmt = [[NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN %@ text", POINT_NAME, POINT_COL_BACKGROUND] UTF8String]; if (sqlite3_exec(tracksDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_BACKGROUND, POINT_NAME, errMsg); + OALog(@"Failed to add column - %@, for table - %@ | error: %s", POINT_COL_BACKGROUND, POINT_NAME, errMsg); } if (errMsg != NULL) sqlite3_free(errMsg); sql_stmt = [[NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN %@ double", TRACK_NAME, TRACK_COL_HEADING] UTF8String]; if (sqlite3_exec(tracksDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to add column - %@, for table - %@ | error: %s", TRACK_COL_HEADING, TRACK_NAME, errMsg); + OALog(@"Failed to add column - %@, for table - %@ | error: %s", TRACK_COL_HEADING, TRACK_NAME, errMsg); } if (errMsg != NULL) sqlite3_free(errMsg); sql_stmt = [[NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN %@ text", TRACK_NAME, TRACK_COL_PLUGINS_INFO] UTF8String]; if (sqlite3_exec(tracksDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to add column - %@, for table - %@ | error: %s", TRACK_COL_PLUGINS_INFO, TRACK_NAME, errMsg); + OALog(@"Failed to add column - %@, for table - %@ | error: %s", TRACK_COL_PLUGINS_INFO, TRACK_NAME, errMsg); } if (errMsg != NULL) sqlite3_free(errMsg); @@ -438,7 +438,7 @@ - (void) saveDataToGpxWithCompletionHandler:(void (^)(void))completionHandler } } else { - NSLog(@"[ERROR] -> OASavingTrackHelper | save gpx"); + OALog(@"[ERROR] -> OASavingTrackHelper | save gpx"); } } @@ -948,7 +948,7 @@ - (void)updatePointCoordinates:(OASWptPt *)wpt newLocation:(CLLocationCoordinate int res = sqlite3_step(statement); if (res != SQLITE_OK && res != SQLITE_DONE) - NSLog(@"updatePointCoordinates failed: sqlite3_step=%d", res); + OALog(@"updatePointCoordinates failed: sqlite3_step=%d", res); sqlite3_finalize(statement); @@ -988,7 +988,7 @@ - (void) doUpdatePointsLat:(double)lat int res = sqlite3_step(statement); if (res != SQLITE_OK && res != SQLITE_DONE) - NSLog(@"doUpdatePointsLat failed: sqlite3_step=%d", res); + OALog(@"doUpdatePointsLat failed: sqlite3_step=%d", res); sqlite3_finalize(statement); diff --git a/Sources/Helpers/OAUtilities.m b/Sources/Helpers/OAUtilities.m index 7976fe957f..dd336f29d1 100644 --- a/Sources/Helpers/OAUtilities.m +++ b/Sources/Helpers/OAUtilities.m @@ -15,6 +15,7 @@ #import "OrderedDictionary.h" #import "OAFileNameTranslationHelper.h" #import "OAOsmAndFormatter.h" +#import "OALog.h" #import "OAColors.h" #import "OASvgHelper.h" #import @@ -2720,7 +2721,7 @@ + (NSAttributedString *) attributedStringFromHtmlString:(NSString *)html fontSiz return [[NSMutableAttributedString alloc] initWithData:[modifiedFontHtml dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute:@(NSUTF8StringEncoding)} documentAttributes:nil error:nil]; } } @catch (NSException *exception) { - NSLog(@"Failed to attributedStringFromHtmlString from: %@ %@", html, exception); + OALog(@"Failed to attributedStringFromHtmlString from: %@ %@", html, exception); return [[NSAttributedString alloc] initWithString:@""]; } } @@ -2773,7 +2774,7 @@ + (natural_t) get_free_memory vm_statistics_data_t vm_stat; if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) { - NSLog(@"Failed to fetch vm statistics"); + OALog(@"Failed to fetch vm statistics"); return 0; } /* Stats in bytes */ diff --git a/Sources/Helpers/OAWebImagesCacheHelper.mm b/Sources/Helpers/OAWebImagesCacheHelper.mm index b64f154e63..71844bb95a 100644 --- a/Sources/Helpers/OAWebImagesCacheHelper.mm +++ b/Sources/Helpers/OAWebImagesCacheHelper.mm @@ -10,6 +10,7 @@ #import "OAWebImagesCacheHelper.h" #import "OADownloadMode.h" #import "OsmAndApp.h" +#import "OALog.h" #import #import "OsmAnd_Maps-Swift.h" @@ -217,7 +218,7 @@ - (void) createDB char *errMsg; if (sqlite3_exec(_database, [@"CREATE TABLE IF NOT EXISTS images (key TEXT, image_base64_data TEXT, timestamp INTEGER);" UTF8String], NULL, NULL, &errMsg) != SQLITE_OK) { - NSLog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); + OALog(@"Failed to create table: %@", [NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]); } if (errMsg != NULL) sqlite3_free(errMsg); sqlite3_close(_database); diff --git a/Sources/Helpers/OAWikiArticleHelper.mm b/Sources/Helpers/OAWikiArticleHelper.mm index 94e08eea5b..2dafcd7d74 100644 --- a/Sources/Helpers/OAWikiArticleHelper.mm +++ b/Sources/Helpers/OAWikiArticleHelper.mm @@ -20,6 +20,7 @@ #import "Localization.h" #import "OAUtilities.h" #import "OAWikiLanguagesWebViewContoller.h" +#import "OALog.h" #include #include @@ -193,7 +194,7 @@ - (BOOL)isUniqueLocation:(CLLocation *)location regionsByLatLon:(NSDictionary #include @@ -125,7 +126,7 @@ - (void) handleImport default: { [OAUtilities denyAccessToFile:destPath removeFromInbox:YES]; - NSLog(@"Could not import: %@", destPath); + OALog(@"Could not import: %@", destPath); } } } diff --git a/Sources/Helpers/OpenLocationCode.swift b/Sources/Helpers/OpenLocationCode.swift index 3bec6506ce..7a44ec3671 100755 --- a/Sources/Helpers/OpenLocationCode.swift +++ b/Sources/Helpers/OpenLocationCode.swift @@ -218,29 +218,29 @@ public struct OpenLocationCodeArea { /// // Encode a location with default code length. /// NSString *code = [OLCConverter encodeLatitude:37.421908 /// longitude:-122.084681]; -/// NSLog(@"Open Location Code: %@", code); -/// +/// OALog(@"Open Location Code: %@", code); +/// /// // Encode a location with specific code length. /// NSString *code10Digit = [OLCConverter encodeLatitude:37.421908 /// longitude:-122.084681 /// codeLength:10]; -/// NSLog(@"Open Location Code: %@", code10Digit); -/// +/// OALog(@"Open Location Code: %@", code10Digit); +/// /// // Decode a full code: /// OLCArea *coord = [OLCConverter decode:@"849VCWC8+Q48"]; -/// NSLog(@"Center is %.6f, %.6f", coord.latitudeCenter, coord.longitudeCenter); -/// +/// OALog(@"Center is %.6f, %.6f", coord.latitudeCenter, coord.longitudeCenter); +/// /// // Attempt to trim the first characters from a code: /// NSString *shortCode = [OLCConverter shortenCode:@"849VCWC8+Q48" /// latitude:37.4 /// longitude:-122.0]; -/// NSLog(@"Short Code: %@", shortCode); -/// +/// OALog(@"Short Code: %@", shortCode); +/// /// // Recover the full code from a short code: /// NSString *recoveredCode = [OLCConverter recoverNearestWithShortcode:@"CWC8+Q48" /// referenceLatitude:37.4 /// referenceLongitude:-122.1]; -/// NSLog(@"Recovered Full Code: %@", recoveredCode); +/// OALog(@"Recovered Full Code: %@", recoveredCode); /// ``` /// public class OpenLocationCode { diff --git a/Sources/Helpers/OpenLocationCodeObjCBridge.swift b/Sources/Helpers/OpenLocationCodeObjCBridge.swift index 1bf4e41d17..f069d0a35e 100755 --- a/Sources/Helpers/OpenLocationCodeObjCBridge.swift +++ b/Sources/Helpers/OpenLocationCodeObjCBridge.swift @@ -108,29 +108,29 @@ import Foundation /// // Encode a location with default code length. /// NSString *code = [OLCConverter encodeLatitude:37.421908 /// longitude:-122.084681]; -/// NSLog(@"Open Location Code: %@", code); -/// +/// OALog(@"Open Location Code: %@", code); +/// /// // Encode a location with specific code length. /// NSString *code10Digit = [OLCConverter encodeLatitude:37.421908 /// longitude:-122.084681 /// codeLength:10]; -/// NSLog(@"Open Location Code: %@", code10Digit); -/// +/// OALog(@"Open Location Code: %@", code10Digit); +/// /// // Decode a full code: /// OLCArea *coord = [OLCConverter decode:@"849VCWC8+Q48"]; -/// NSLog(@"Center is %.6f, %.6f", coord.latitudeCenter, coord.longitudeCenter); +/// OALog(@"Center is %.6f, %.6f", coord.latitudeCenter, coord.longitudeCenter); /// /// // Attempt to trim the first characters from a code: /// NSString *shortCode = [OLCConverter shortenCode:@"849VCWC8+Q48" /// latitude:37.4 /// longitude:-122.0]; -/// NSLog(@"Short Code: %@", shortCode); -/// +/// OALog(@"Short Code: %@", shortCode); +/// /// // Recover the full code from a short code: /// NSString *recoveredCode = [OLCConverter recoverNearestWithShortcode:@"CWC8+Q48" /// referenceLatitude:37.4 /// referenceLongitude:-122.1]; -/// NSLog(@"Recovered Full Code: %@", recoveredCode); +/// OALog(@"Recovered Full Code: %@", recoveredCode); /// ``` /// @objc public class OLCConverter: NSObject { diff --git a/Sources/Helpers/OrderedDictionary.m b/Sources/Helpers/OrderedDictionary.m index 77ee471074..3cb26dbb12 100644 --- a/Sources/Helpers/OrderedDictionary.m +++ b/Sources/Helpers/OrderedDictionary.m @@ -31,6 +31,7 @@ // #import "OrderedDictionary.h" +#import "OALog.h" #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" @@ -55,28 +56,28 @@ @implementation OrderedDictionary + (instancetype)dictionaryWithContentsOfFile:(__unused NSString *)path { - NSLog(@"OrderedDictionary does not support loading from a plist file. Use NSKeyedArchiver instead."); + OALog(@"OrderedDictionary does not support loading from a plist file. Use NSKeyedArchiver instead."); [self doesNotRecognizeSelector:_cmd]; return nil; } + (instancetype)dictionaryWithContentsOfURL:(__unused NSURL *)url { - NSLog(@"OrderedDictionary does not support loading from a plist file. Use NSKeyedArchiver instead."); + OALog(@"OrderedDictionary does not support loading from a plist file. Use NSKeyedArchiver instead."); [self doesNotRecognizeSelector:_cmd]; return nil; } - (instancetype)initWithContentsOfFile:(__unused NSString *)path { - NSLog(@"OrderedDictionary does not support loading from a plist file. Use NSKeyedArchiver instead."); + OALog(@"OrderedDictionary does not support loading from a plist file. Use NSKeyedArchiver instead."); [self doesNotRecognizeSelector:_cmd]; return nil; } - (instancetype)initWithContentsOfURL:(__unused NSURL *)url { - NSLog(@"OrderedDictionary does not support loading from a plist file. Use NSKeyedArchiver instead."); + OALog(@"OrderedDictionary does not support loading from a plist file. Use NSKeyedArchiver instead."); [self doesNotRecognizeSelector:_cmd]; return nil; } diff --git a/Sources/Helpers/SharedLibHelpers/OASharedUtil.m b/Sources/Helpers/SharedLibHelpers/OASharedUtil.m index d9b0e1d18e..25db2ae984 100644 --- a/Sources/Helpers/SharedLibHelpers/OASharedUtil.m +++ b/Sources/Helpers/SharedLibHelpers/OASharedUtil.m @@ -9,6 +9,7 @@ #import "OASharedUtil.h" #import "OsmAndApp.h" #import "OAXmlFactory.h" +#import "OALog.h" #import "OAOsmAndContextImpl.h" #import @@ -23,17 +24,17 @@ + (void)initSharedLib:(NSString *)documentsPath gpxPath:(NSString *)gpxPath // Temporary test code + (void) testGpxReadWrite:(NSString *)inputFile outputFile:(NSString *)outputFile { - NSLog(@"GPX TEST - READ"); + OALog(@"GPX TEST - READ"); OASKFile *file = [[OASKFile alloc] initWithFilePath:inputFile]; OASGpxFile *gpxFile = [OASGpxUtilities.shared loadGpxFileFile:file]; - NSLog(@"GPX TEST - WRITE"); + OALog(@"GPX TEST - WRITE"); file = [[OASKFile alloc] initWithFilePath:outputFile]; [OASGpxUtilities.shared writeGpxFileFile:file gpxFile:gpxFile]; - NSLog(@"GPX TEST - DONE"); + OALog(@"GPX TEST - DONE"); } diff --git a/Sources/OsmAnd Maps-Bridging-Header.h b/Sources/OsmAnd Maps-Bridging-Header.h index f2c5aeb6f0..d860c08220 100644 --- a/Sources/OsmAnd Maps-Bridging-Header.h +++ b/Sources/OsmAnd Maps-Bridging-Header.h @@ -66,6 +66,7 @@ #import "OALocationIcon.h" #import "OrderedDictionary.h" #import "OAMapActions.h" +#import "OALog.h" // Widgets #import "OAMapWidgetRegistry.h" diff --git a/Sources/OsmEdit/OAOpenStreetMapRemoteUtil.mm b/Sources/OsmEdit/OAOpenStreetMapRemoteUtil.mm index bafcb2cf29..c19e7dc348 100644 --- a/Sources/OsmEdit/OAOpenStreetMapRemoteUtil.mm +++ b/Sources/OsmEdit/OAOpenStreetMapRemoteUtil.mm @@ -28,6 +28,7 @@ #import "OANetworkUtilities.h" #import "OAURLSessionProgress.h" #import "OAGPXDatabase.h" +#import "OALog.h" #import "OsmAndApp.h" #import "OsmAnd_Maps-Swift.h" @@ -118,7 +119,7 @@ - (void) uploadGPXFile:(NSString *)tagstring description:(NSString *)description -(NSString *)sendRequest:(NSString *)url requestMethod:(NSString *)requestMethod requestBody:(NSString *)requestBody userOperation:(NSString *)userOperation doAuthenticate:(BOOL)doAuthenticate { - NSLog(@"Sending request: %@", url); + OALog(@"Sending request: %@", url); NSURL *urlObj = [[NSURL alloc] initWithString:url]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlObj cachePolicy:NSURLRequestReloadIgnoringLocalCacheData @@ -284,7 +285,7 @@ - (void)closeChangeSet NSString *response = [self sendRequest:[NSString stringWithFormat:@"%@%@%ld%@", BASE_URL, @"api/0.6/changeset/", _changeSetId, @"/close"] requestMethod:@"PUT" requestBody:@"" userOperation:OALocalizedString(@"closing_changeset") doAuthenticate:YES]; - NSLog(@"Response: %@", response); + OALog(@"Response: %@", response); _changeSetId = NO_CHANGESET_ID; } } @@ -327,7 +328,7 @@ - (OAEntity *)commitEntityImpl:(EOAAction)action entity:(OAEntity *)entity entit NSString *res = [self sendRequest:[NSString stringWithFormat:@"%@%@%ld%@", BASE_URL, @"api/0.6/changeset/", _changeSetId, @"/upload"] requestMethod:@"POST" requestBody:xmlString userOperation:OALocalizedString(@"commiting_node") doAuthenticate:YES]; - NSLog(@"Response: %@", res); + OALog(@"Response: %@", res); if (res) { if (CREATE == action) { long long newId = [entity getId]; diff --git a/Sources/OsmEdit/OAOsmBugsRemoteUtil.m b/Sources/OsmEdit/OAOsmBugsRemoteUtil.m index edecb85898..705d41d7c8 100644 --- a/Sources/OsmEdit/OAOsmBugsRemoteUtil.m +++ b/Sources/OsmEdit/OAOsmBugsRemoteUtil.m @@ -10,6 +10,7 @@ #import "OAOsmNotePoint.h" #import "OAOsmBugResult.h" #import "OAAppSettings.h" +#import "OALog.h" #import "OsmAnd_Maps-Swift.h" #define GET @"GET" @@ -68,7 +69,7 @@ -(OAOsmBugResult *)validateLoginDetails -(OAOsmBugResult *) editingPOI:(NSString *)url requestMethod:(NSString *)requestMethod userOperation:(NSString *)userOperation anonymous:(BOOL) anonymous { - NSLog(@"Sending request: %@", url); + OALog(@"Sending request: %@", url); NSURL *urlObj = [[NSURL alloc] initWithString:url]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlObj cachePolicy:NSURLRequestReloadIgnoringLocalCacheData diff --git a/Sources/OsmEdit/OsmData/OAOsmBaseStorage.m b/Sources/OsmEdit/OsmData/OAOsmBaseStorage.m index 0ad4160f2e..3638106243 100644 --- a/Sources/OsmEdit/OsmData/OAOsmBaseStorage.m +++ b/Sources/OsmEdit/OsmData/OAOsmBaseStorage.m @@ -14,6 +14,7 @@ #import "OAEntityInfo.h" #import "OrderedDictionary.h" #import "OAEntityInfo.h" +#import "OALog.h" // called from libxml functions @interface OAOsmBaseStorage (LibXMLParserMethods) @@ -278,7 +279,7 @@ - (void)elementFound:(const xmlChar *)localname prefix:(const xmlChar *)prefix else { // this situation could be logged as unhandled - NSLog(@"%@", @"Bad entity type from OSC request"); + OALog(@"%@", @"Bad entity type from OSC request"); } if (_currentParsedEntity) diff --git a/Sources/POI/OAPOIHelper.mm b/Sources/POI/OAPOIHelper.mm index 2e9c664bfc..c85b8c12d8 100644 --- a/Sources/POI/OAPOIHelper.mm +++ b/Sources/POI/OAPOIHelper.mm @@ -24,6 +24,7 @@ #import "OAResultMatcher.h" #import "Localization.h" #import "OANativeUtilities.h" +#import "OALog.h" #include #include @@ -127,7 +128,7 @@ - (void) findDefaultOtherCategory { OAPOICategory *pc = [self getPoiCategoryByName:@"user_defined_other"]; if (!pc) - NSLog(@"!!! 'user_defined_other' category not found"); + OALog(@"!!! 'user_defined_other' category not found"); _otherPoiCategory = pc; } @@ -198,7 +199,7 @@ - (void) updatePhrases if (!_phrases) { - NSLog(@"ERROR: Not found phrases translation file at path: %@", [NSString stringWithFormat:@"phrases/%@/phrases.xml", fullLanguageCode]); + OALog(@"ERROR: Not found phrases translation file at path: %@", [NSString stringWithFormat:@"phrases/%@/phrases.xml", fullLanguageCode]); NSString *primaryLanguageCode = [OAUtilities currentLang]; _phrases = [self loadPhraseFileForLanguage:primaryLanguageCode]; } diff --git a/Sources/Plugins/OAOnlinePlugin.mm b/Sources/Plugins/OAOnlinePlugin.mm index d93079f031..7bc5811171 100644 --- a/Sources/Plugins/OAOnlinePlugin.mm +++ b/Sources/Plugins/OAOnlinePlugin.mm @@ -14,6 +14,7 @@ #import #import "OASettingsItem.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" @interface OAOnlinePlugin() @@ -106,7 +107,7 @@ - (void) install:(id _Nullable)callback { if (_osfUrl.length == 0) { - NSLog(@"Cannot install online plugin. OSF url is empty for %@", self.getId); + OALog(@"Cannot install online plugin. OSF url is empty for %@", self.getId); return; } diff --git a/Sources/Plugins/OAPluginsHelper.mm b/Sources/Plugins/OAPluginsHelper.mm index e9c469e364..58dfa549de 100644 --- a/Sources/Plugins/OAPluginsHelper.mm +++ b/Sources/Plugins/OAPluginsHelper.mm @@ -35,6 +35,7 @@ #import "OAAppVersion.h" #import "OAOnlinePlugin.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" @implementation OAPluginsHelper @@ -163,7 +164,7 @@ + (void) initPlugin:(OAPlugin *)plugin } @catch (NSException *e) { - NSLog(@"Plugin initialization failed %@ reason=%@", [plugin getId], e.reason); + OALog(@"Plugin initialization failed %@ reason=%@", [plugin getId], e.reason); } } diff --git a/Sources/Purchases/OAIAPHelper.mm b/Sources/Purchases/OAIAPHelper.mm index e079102b96..64fbd394e2 100644 --- a/Sources/Purchases/OAIAPHelper.mm +++ b/Sources/Purchases/OAIAPHelper.mm @@ -17,6 +17,7 @@ #import "OAObservable.h" #import "OAAppSettings.h" #import "OAProducts.h" +#import "OALog.h" #import NSString *const OAIAPProductsRequestSucceedNotification = @"OAIAPProductsRequestSucceedNotification"; @@ -175,7 +176,7 @@ + (int) freeMapsAvailable [[NSUserDefaults standardUserDefaults] setInteger:kFreeMapsAvailableTotal forKey:@"freeMapsAvailable"]; } - NSLog(@"Free maps available: %d", freeMaps); + OALog(@"Free maps available: %d", freeMaps); return freeMaps; } @@ -188,7 +189,7 @@ + (void) decreaseFreeMapsCount [[NSUserDefaults standardUserDefaults] setInteger:--freeMaps forKey:@"freeMapsAvailable"]; [[NSUserDefaults standardUserDefaults] synchronize]; - NSLog(@"Free maps left: %d", freeMaps); + OALog(@"Free maps left: %d", freeMaps); } + (void) increaseFreeMapsCount:(int)count @@ -201,7 +202,7 @@ + (void) increaseFreeMapsCount:(int)count [[NSUserDefaults standardUserDefaults] setInteger:freeMaps forKey:@"freeMapsAvailable"]; [[NSUserDefaults standardUserDefaults] synchronize]; - NSLog(@"Free maps left: %d", freeMaps); + OALog(@"Free maps left: %d", freeMaps); } + (BOOL) isPaidVersion @@ -679,7 +680,7 @@ - (void) enableProduct:(NSString *)productIdentifier - (void) buyProduct:(OAProduct *)product { - NSLog(@"Buying %@...", product.productIdentifier); + OALog(@"Buying %@...", product.productIdentifier); // test - emulate purchasing if (TEST_LOCAL_PURCHASE) @@ -763,7 +764,7 @@ - (void) buySubscription:(OASubscription *)subscription if (map) { NSString *userId = [map objectForKey:@"userid"]; - NSLog(@"UserId = %@", userId); + OALog(@"UserId = %@", userId); if (userId.length > 0) { [self applyUserPreferences:map]; @@ -819,7 +820,7 @@ - (void) buySubscription:(OASubscription *)subscription - (void) launchPurchase:(OASubscription *)subscription { - NSLog(@"Launching purchase flow for live updates subscription"); + OALog(@"Launching purchase flow for live updates subscription"); OAPaymentDiscount *paymentDiscount = nil; if (_settings.eligibleForSubscriptionOffer && subscription.discounts.count > 0) { @@ -861,7 +862,7 @@ - (OASubscription *) getCheapestMonthlySubscription - (void) productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { - NSLog(@"Loaded list of products..."); + OALog(@"Loaded list of products..."); _productsRequest = nil; BOOL isPaidVersion = [self.class isPaidVersion]; BOOL isOsmAndProAvailable = [self.class isOsmAndProAvailable]; @@ -870,7 +871,7 @@ - (void) productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProd { if (skProduct) { - NSLog(@"Found product: %@ %@ %0.2f", + OALog(@"Found product: %@ %@ %0.2f", skProduct.productIdentifier, skProduct.localizedTitle, skProduct.price.floatValue); @@ -1055,17 +1056,17 @@ - (void) requestDidFinish:(SKRequest *)request { if (request == _productsRequest) { - NSLog(@"Products request did finish OK"); + OALog(@"Products request did finish OK"); } else if (request == _receiptRequest) { - NSLog(@"Receipt request did finish OK"); + OALog(@"Receipt request did finish OK"); _receiptRequest = nil; [self getActiveProducts:_activeProductsCompletionHandler]; } else { - NSLog(@"SKRequest did finish OK"); + OALog(@"SKRequest did finish OK"); } } @@ -1079,7 +1080,7 @@ - (void) request:(SKRequest *)request didFailWithError:(NSError *)error else requestName = @"Unknown"; - NSLog(@"%@ request did fail with error: %@", requestName, error.localizedDescription); + OALog(@"%@ request did fail with error: %@", requestName, error.localizedDescription); if (request == _productsRequest) { @@ -1181,11 +1182,11 @@ - (void) completeTransaction:(SKPaymentTransaction *)transaction { if (![self productsLoaded]) { - NSLog(@"Cannot completeTransaction - %@. Products are not loaded yet.", transaction.payment.productIdentifier); + OALog(@"Cannot completeTransaction - %@. Products are not loaded yet.", transaction.payment.productIdentifier); } else { - NSLog(@"completeTransaction - %@", transaction.payment.productIdentifier); + OALog(@"completeTransaction - %@", transaction.payment.productIdentifier); NSString *productId = transaction.payment.productIdentifier; NSString *transactionId = transaction.originalTransaction ? transaction.originalTransaction.transactionIdentifier : transaction.transactionIdentifier; [self provideContentForProductIdentifier:productId transactionId:transactionId]; @@ -1206,11 +1207,11 @@ - (void) restoreTransaction:(SKPaymentTransaction *)transaction { if (![self productsLoaded]) { - NSLog(@"Cannot restoreTransaction - %@. Products are not loaded yet.", transaction.originalTransaction.payment.productIdentifier); + OALog(@"Cannot restoreTransaction - %@. Products are not loaded yet.", transaction.originalTransaction.payment.productIdentifier); } else { - NSLog(@"restoreTransaction - %@", transaction.originalTransaction.payment.productIdentifier); + OALog(@"restoreTransaction - %@", transaction.originalTransaction.payment.productIdentifier); } } [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; @@ -1221,7 +1222,7 @@ - (void) restoreTransaction:(SKPaymentTransaction *)transaction - (void) deferredTransaction:(SKPaymentTransaction *)transaction { @synchronized (self) { - NSLog(@"Transaction deferred state: %@", transaction.payment.productIdentifier); + OALog(@"Transaction deferred state: %@", transaction.payment.productIdentifier); [[NSNotificationCenter defaultCenter] postNotificationName:OAIAPProductPurchaseDeferredNotification object:transaction.payment.productIdentifier userInfo:nil]; } } @@ -1234,11 +1235,11 @@ - (void) failedTransaction:(SKPaymentTransaction *)transaction if (transaction.payment && transaction.payment.productIdentifier) { NSString *productIdentifier = transaction.payment.productIdentifier; - NSLog(@"failedTransaction - %@", productIdentifier); + OALog(@"failedTransaction - %@", productIdentifier); [self logTransactionType:@"failed" productIdentifier:productIdentifier]; if (transaction.error && transaction.error.code != SKErrorPaymentCancelled) { - NSLog(@"Transaction error: %@", transaction.error.localizedDescription); + OALog(@"Transaction error: %@", transaction.error.localizedDescription); [[NSNotificationCenter defaultCenter] postNotificationName:OAIAPProductPurchaseFailedNotification object:productIdentifier userInfo:@{@"error" : [NSString stringWithFormat:@"failedTransaction %@ - %@", productIdentifier, transaction.error.localizedDescription]}]; } else @@ -1357,7 +1358,7 @@ - (void) provideContentForProductIdentifier:(NSString * _Nonnull)productIdentifi OAProduct *product = [self product:productIdentifier]; if (product) { - NSLog(@"%@ product purchased.", product.localizedTitle); + OALog(@"%@ product purchased.", product.localizedTitle); // test - emulate purchase if (TEST_LOCAL_PURCHASE) @@ -1407,7 +1408,7 @@ - (void) provideContentForProductIdentifier:(NSString * _Nonnull)productIdentifi NSData *receipt = [self getLocalReceipt]; if (!receipt || !transactionId) { - NSLog(@"Error: No local receipt or transaction"); + OALog(@"Error: No local receipt or transaction"); NSMutableString *errorText = [NSMutableString string]; if (!receipt) [errorText appendString:@" (no receipt)"]; @@ -1451,7 +1452,7 @@ - (void) provideContentForProductIdentifier:(NSString * _Nonnull)productIdentifi { @try { - NSLog([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + OALog([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); NSMutableDictionary *map = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; if (map) { @@ -1465,7 +1466,7 @@ - (void) provideContentForProductIdentifier:(NSString * _Nonnull)productIdentifi else { errorStr = [NSString stringWithFormat:@"Purchase subscription failed: %@ (userId=%@ response=%@)", [map objectForKey:@"error"], _settings.billingUserId.get, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]]; - NSLog(errorStr); + OALog(errorStr); } } } @@ -1550,7 +1551,7 @@ - (void) getActiveProducts:(RequestActiveProductsCompletionHandler)onComplete if (!receipt || _restoringPurchases) { if (!_restoringPurchases) - NSLog(@"No local receipt. Requesting new one..."); + OALog(@"No local receipt. Requesting new one..."); _restoringPurchases = NO; _activeProductsCompletionHandler = onComplete; _receiptRequest = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:nil]; @@ -1576,7 +1577,7 @@ - (void) getActiveProducts:(RequestActiveProductsCompletionHandler)onComplete { @try { - NSLog([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + OALog([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); NSMutableDictionary *map = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; if (map) { @@ -1721,7 +1722,7 @@ - (void) fetchSubscriptionOfferSignatures:(void (^)(void))onComplete API_AVAILAB { @try { - NSLog([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + OALog([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); NSMutableDictionary *map = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; if (map) { @@ -1907,7 +1908,7 @@ - (NSString *) getOrderIdByDeviceIdAndToken } else { - NSLog(@"Subscription validation json error"); + OALog(@"Subscription validation json error"); } } alreadyFinished = YES; diff --git a/Sources/QuickAction/OAMapButtonsHelper.m b/Sources/QuickAction/OAMapButtonsHelper.m index c2d28ebf0b..082d75c686 100644 --- a/Sources/QuickAction/OAMapButtonsHelper.m +++ b/Sources/QuickAction/OAMapButtonsHelper.m @@ -36,6 +36,7 @@ #import "OAShowHideMapillaryAction.h" #import "OAPluginsHelper.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" static NSString * const kType = @"type"; static NSString * const kName = @"name"; @@ -360,7 +361,7 @@ - (void)updateActiveActions } @catch (NSException *e) { - NSLog(@"%@", e.reason); + OALog(@"%@", e.reason); } } } diff --git a/Sources/Router/Colorization/OARouteColorize.mm b/Sources/Router/Colorization/OARouteColorize.mm index 3b5a28eb52..867f95afd7 100644 --- a/Sources/Router/Colorization/OARouteColorize.mm +++ b/Sources/Router/Colorization/OARouteColorize.mm @@ -15,6 +15,7 @@ #import "OsmAnd_Maps-Swift.h" #import #import "OsmAndSharedWrapper.h" +#import "OALog.h" static CGFloat const defaultBase = 17.2; static CGFloat const maxCorrectElevationDistance = 100.0; // in meters @@ -59,7 +60,7 @@ - (instancetype) initWithGpxFile:(OASGpxFile *)gpxFile { if (!gpxFile.hasTrkPt) { - NSLog(@"GPX file is not consist of track points"); + OALog(@"GPX file is not consist of track points"); return nil; } self = [super init]; @@ -145,7 +146,7 @@ - (BOOL)isValidPalette:(ColorPalette *)palette NSMutableArray *slopes = [NSMutableArray arrayWithCapacity:elevations.count]; if (_latitudes.count != _longitudes.count || _latitudes.count != elevations.count) { - NSLog(@"Sizes of arrays latitudes, longitudes and values are not match"); + OALog(@"Sizes of arrays latitudes, longitudes and values are not match"); return slopes; } @@ -320,7 +321,7 @@ - (void)setColorsToPoints:(NSArray *)points double diff = distances[closestMaxIndex].doubleValue - distances[closestMaxIndex - 1].doubleValue; double coef = (maxDist - distances[closestMaxIndex - 1].doubleValue) / diff; if (coef > 1 || coef < 0) - NSLog(@"Coefficient fo max must be 0..1 , coef=%f", coef); + OALog(@"Coefficient fo max must be 0..1 , coef=%f", coef); result[1] = @((1 - coef) * elevations[closestMaxIndex - 1].doubleValue + coef * elevations[closestMaxIndex].doubleValue); } @@ -329,11 +330,11 @@ - (void)setColorsToPoints:(NSArray *)points double diff = distances[closestMinIndex + 1].doubleValue - distances[closestMinIndex].doubleValue; double coef = (minDist - distances[closestMinIndex].doubleValue) / diff; if (coef > 1 || coef < 0) - NSLog(@"Coefficient for min must be 0..1 , coef=%f", coef); + OALog(@"Coefficient for min must be 0..1 , coef=%f", coef); result[0] = @((1 - coef) * elevations[closestMinIndex].doubleValue + coef * elevations[closestMinIndex + 1].doubleValue); } if (isnan(result[0].doubleValue) || isnan(result[1].doubleValue)) - NSLog(@"Elevations weren't calculated"); + OALog(@"Elevations weren't calculated"); return result; } diff --git a/Sources/Router/GPX/OATspAnt.m b/Sources/Router/GPX/OATspAnt.m index 160e01a37f..40baa92185 100644 --- a/Sources/Router/GPX/OATspAnt.m +++ b/Sources/Router/GPX/OATspAnt.m @@ -7,6 +7,7 @@ // #import "OATspAnt.h" +#import "OALog.h" // Algorithm parameters: // original amount of trail @@ -64,7 +65,7 @@ - (instancetype)initWithGraph:(NSMutableArray *)graph n:(int)n currentIndex:(int - (void)visitTown:(int)town { - //NSLog(@"town = %d", town); + //OALog(@"town = %d", town); self.tour[*_currentIndex + 1] = [NSNumber numberWithInt:town]; self.visited[town] = @YES; @@ -392,8 +393,8 @@ - (NSArray *)solve iteration++; } // Subtract n because we added one to edges on load - NSLog(@"Best tour length: %f", bestTourLength - n * 0.1); - NSLog(@"Best tour: %@", [self tourToString:bestTour]); + OALog(@"Best tour length: %f", bestTourLength - n * 0.1); + OALog(@"Best tour: %@", [self tourToString:bestTour]); return [self alignAnswer:[bestTour copy]]; } @@ -456,7 +457,7 @@ - (void)test } [mixStr appendString:@"]"]; - NSLog(@"%@", mixStr); + OALog(@"%@", mixStr); // ans = new TspHeldKarp().readInput(sh, true).solve(); CLLocation *end = farest; @@ -501,14 +502,14 @@ - (void)test for (int i = 0; i < ans.count; i++) [log appendFormat:@"%d ", order[i]]; - NSLog(@"%@", log); + OALog(@"%@", log); log = [NSMutableString string]; [log appendString:@"Result dist: "]; for (int i = 1; i < ans.count - 1; i++) [log appendFormat:@"%f ", dist[i]]; - NSLog(@"%@", log); + OALog(@"%@", log); } @end diff --git a/Sources/Router/OARouteImporter.mm b/Sources/Router/OARouteImporter.mm index a6def2dbe8..7b6b8fca80 100644 --- a/Sources/Router/OARouteImporter.mm +++ b/Sources/Router/OARouteImporter.mm @@ -8,6 +8,7 @@ #import "OARouteImporter.h" #import "OAGPXDocumentPrimitives.h" +#import "OALog.h" #include #include @@ -154,7 +155,7 @@ - (void) collectLocations:(std::shared_ptr &)resources segme } catch (const std::exception &ex) { - NSLog(@"%s", ex.what()); + OALog(@"%s", ex.what()); } } return route; diff --git a/Sources/Router/OARouteProvider.mm b/Sources/Router/OARouteProvider.mm index 1b107ae41a..fd97adf643 100644 --- a/Sources/Router/OARouteProvider.mm +++ b/Sources/Router/OARouteProvider.mm @@ -29,6 +29,7 @@ #import "CLLocation+Extension.h" #import "OsmAndSharedWrapper.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" #include #include @@ -703,7 +704,7 @@ - (OARouteCalculationResult *) emptyResult long memoryLimit = (0.1 * ([NSProcessInfo processInfo].physicalMemory / mb)); // make visible long memoryTotal = (long) ([NSProcessInfo processInfo].physicalMemory / mb); - NSLog(@"Use %ld MB of %ld MB, free memory: %ld MB", memoryLimit, memoryTotal, (long)(freeMemory / mb)); + OALog(@"Use %ld MB of %ld MB, free memory: %ld MB", memoryLimit, memoryTotal, (long)(freeMemory / mb)); string routingProfile = derivedProfile == "default" ? params.mode.getRoutingProfile.UTF8String : derivedProfile; auto cf = config->build(routingProfile, params.start.course >= 0.0 ? params.start.course / 180.0 * M_PI : NO_DIRECTION, memoryLimit, paramsR); @@ -1666,7 +1667,7 @@ - (OARouteCalculationResult *) calculateRouteImpl:(OARouteCalculationParams *)pa if (params.start && params.end) { // params.calculationProgress->routeCalculationStartTime = time; - NSLog(@"Start finding route from %@ to %@ using %@", params.start, params.end, [OARouteService getName:(EOARouteService)params.mode.getRouterService]); + OALog(@"Start finding route from %@ to %@ using %@", params.start, params.end, [OARouteService getName:(EOARouteService)params.mode.getRouterService]); try { OARouteCalculationResult *res = nil; @@ -1713,14 +1714,14 @@ - (OARouteCalculationResult *) calculateRouteImpl:(OARouteCalculationParams *)pa if (res) { - NSLog(@"Finding route contained %d points for %.3f s", (int)[res getImmutableAllLocations].count, [[NSDate date] timeIntervalSince1970] - time); + OALog(@"Finding route contained %d points for %.3f s", (int)[res getImmutableAllLocations].count, [[NSDate date] timeIntervalSince1970] - time); } return res; } catch (NSException *e) { - NSLog(@"Failed to find route %@", e.reason); + OALog(@"Failed to find route %@", e.reason); } } return [[OARouteCalculationResult alloc] initWithErrorMessage:nil]; diff --git a/Sources/Router/OARoutingHelper.mm b/Sources/Router/OARoutingHelper.mm index b3ccf25fd2..7e7ab70b23 100644 --- a/Sources/Router/OARoutingHelper.mm +++ b/Sources/Router/OARoutingHelper.mm @@ -37,6 +37,7 @@ #import #import "OsmAndSharedWrapper.h" #import "OsmAnd_Maps-Swift.h" +#import "OALog.h" #include @@ -453,7 +454,7 @@ - (int) calculateCurrentRoute:(CLLocation *)currentLocation posTolerance:(float) { if (newDist < dist) { - NSLog(@"Processed by distance : (new) %f (old) %f", newDist, dist); + OALog(@"Processed by distance : (new) %f (old) %f", newDist, dist); processed = true; } } @@ -463,7 +464,7 @@ - (int) calculateCurrentRoute:(CLLocation *)currentLocation posTolerance:(float) if (dist > posTolerance) { processed = true; - NSLog(@"Processed by distance : %f %f", newDist, dist); + OALog(@"Processed by distance : %f %f", newDist, dist); } else { @@ -482,7 +483,7 @@ - (int) calculateCurrentRoute:(CLLocation *)currentLocation posTolerance:(float) double diffToNext = ABS(degreesDiff(bearingMotion, bearingRouteNext)); if (diff > diffToNext) { - NSLog(@"Processed point bearing deltas : %f %f", diff, diffToNext); + OALog(@"Processed point bearing deltas : %f %f", diff, diffToNext); processed = true; } } @@ -712,7 +713,7 @@ - (CLLocation *) setCurrentLocation:(CLLocation *)currentLocation returnUpdatedL } if (distOrth > allowableDeviation) { - NSLog(@"Recalculate route, because correlation : %f", distOrth); + OALog(@"Recalculate route, because correlation : %f", distOrth); _isDeviatedFromRoute = true; calculateRoute = ![_settings.disableOffrouteRecalc get]; } @@ -725,7 +726,7 @@ - (CLLocation *) setCurrentLocation:(CLLocation *)currentLocation returnUpdatedL if (allowableDeviation > 0 && wrongMovementDirection && !isStraight && ([currentLocation distanceFromLocation:routeNodes[currentRoute]] > allowableDeviation) && ![_settings.disableWrongDirectionRecalc get]) { - NSLog(@"Recalculate route, because wrong movement direction: %f", [currentLocation distanceFromLocation:routeNodes[currentRoute]]); + OALog(@"Recalculate route, because wrong movement direction: %f", [currentLocation distanceFromLocation:routeNodes[currentRoute]]); _isDeviatedFromRoute = true; calculateRoute = true; } diff --git a/Sources/Router/OATransportRoutingHelper.mm b/Sources/Router/OATransportRoutingHelper.mm index 3fab62fd92..4b8818a655 100644 --- a/Sources/Router/OATransportRoutingHelper.mm +++ b/Sources/Router/OATransportRoutingHelper.mm @@ -18,6 +18,7 @@ #import "QuadRect.h" #import "OARouteProvider.h" #import "OARootViewController.h" +#import "OALog.h" #include #include @@ -832,7 +833,7 @@ - (void) setNewRoute:(std::vector>)res { [listener newRouteIsCalculated:YES]; } - NSLog(@"Public transport routes calculated: %ld", res.size()); + OALog(@"Public transport routes calculated: %ld", res.size()); }); } @@ -882,7 +883,7 @@ - (void) setCurrentLocation:(CLLocation *) currentLocation - (void) showMessage:(NSString *)msg { - NSLog(@"Public Transport error: %@", msg); + OALog(@"Public Transport error: %@", msg); } diff --git a/Sources/Search/OASearchUICore.mm b/Sources/Search/OASearchUICore.mm index 7494a94639..1cda6c2906 100644 --- a/Sources/Search/OASearchUICore.mm +++ b/Sources/Search/OASearchUICore.mm @@ -23,6 +23,7 @@ #import "OAPOIBaseType.h" #import "OAStreet.h" #import "OAResultMatcher.h" +#import "OALog.h" #include #include @@ -529,7 +530,7 @@ - (OASearchResultCollection *) shallowSearch:(Class)cl text:(NSString *)text mat OASearchResultCollection *collection = [[OASearchResultCollection alloc] initWithPhrase:sphrase]; [collection addSearchResults:[rm getRequestResults] resortAll:resortAll removeDuplicates:removeDuplicates]; - NSLog(@">> Shallow Search phrase %@ %d", [_phrase toString], (int)([rm getRequestResults].count)); + OALog(@">> Shallow Search phrase %@ %d", [_phrase toString], (int)([rm getRequestResults].count)); return collection; } @@ -653,7 +654,7 @@ - (void) search:(NSString *)text delayedExecution:(BOOL)delayedExecution matcher _searchActive = YES; OASearchPhrase *phrase = [_phrase generateNewPhrase:text settings:_searchSettings]; _phrase = phrase; - NSLog(@"> Search phrase %@", [_phrase toString]); + OALog(@"> Search phrase %@", [_phrase toString]); dispatch_async(_taskQueue, ^{ @try @@ -706,7 +707,7 @@ - (void) search:(NSString *)text delayedExecution:(BOOL)delayedExecution matcher { OASearchResultCollection *collection = [[OASearchResultCollection alloc] initWithPhrase:phrase]; [collection addSearchResults:[rm getRequestResults] resortAll:YES removeDuplicates:YES]; - NSLog(@">> Search phrase %@ %d", [phrase toString], (int)([rm getRequestResults].count)); + OALog(@">> Search phrase %@ %d", [phrase toString], (int)([rm getRequestResults].count)); _currentSearchResult = collection; [rm searchFinished:phrase]; if (_onResultsComplete) @@ -715,7 +716,7 @@ - (void) search:(NSString *)text delayedExecution:(BOOL)delayedExecution matcher } @catch (NSException *e) { - NSLog(@"OASearchUICore.search error %@", e); + OALog(@"OASearchUICore.search error %@", e); } @finally { @@ -810,7 +811,7 @@ - (void) searchInBackground:(OASearchPhrase *)phrase matcher:(OASearchResultMatc } catch (NSException *e) { - NSLog(@"OASearchUICore.searchInBackground error %@", e); + OALog(@"OASearchUICore.searchInBackground error %@", e); } if ([api isSearchDone:phrase]) diff --git a/Sources/Views/OAFreeMemoryView.m b/Sources/Views/OAFreeMemoryView.m index 9b5d536b2a..c25ecf7895 100644 --- a/Sources/Views/OAFreeMemoryView.m +++ b/Sources/Views/OAFreeMemoryView.m @@ -10,6 +10,7 @@ #import "Localization.h" #import "OsmAnd_Maps-Swift.h" #import "GeneratedAssetSymbols.h" +#import "OALog.h" @implementation OAFreeMemoryView { @@ -105,7 +106,7 @@ - (void) update deviceMemoryCapacity = [fileSystemSizeInBytes unsignedLongLongValue]; if (deviceMemoryCapacity <= 0) { - NSLog(@"Error obtaining dvice memory capacity"); + OALog(@"Error obtaining dvice memory capacity"); deviceMemoryCapacity = 1; } @@ -122,7 +123,7 @@ - (void) update } else { - NSLog(@"Error Obtaining File System Info: Domain = %@, Code = %ld", [error domain], (long)[error code]); + OALog(@"Error Obtaining File System Info: Domain = %@, Code = %ld", [error domain], (long)[error code]); } unsigned long long docSize = [OAUtilities folderSize:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]]; @@ -140,7 +141,7 @@ - (void) update double sum = _sysVal + _appVal + _freeVal; if (sum > 1.5 || sum <= 0) { - NSLog(@"Incorrect storage calculation (total:%llu, system:%llu, free:%llu, doc:%llu)", capValue, systemValue, availValue, docValue); + OALog(@"Incorrect storage calculation (total:%llu, system:%llu, free:%llu, doc:%llu)", capValue, systemValue, availValue, docValue); _sysVal = 0; _appVal = 0; _freeVal = 1; diff --git a/Sources/Voice/OATTSCommandPlayerImpl.mm b/Sources/Voice/OATTSCommandPlayerImpl.mm index c589d9dc30..afa292e9d1 100644 --- a/Sources/Voice/OATTSCommandPlayerImpl.mm +++ b/Sources/Voice/OATTSCommandPlayerImpl.mm @@ -14,6 +14,7 @@ #import "OAAppSettings.h" #import "OARootViewController.h" #import "Localization.h" +#import "OALog.h" #include @@ -92,7 +93,7 @@ - (AVSpeechSynthesisVoice *)voiceToUse { [OAUtilities showToast:OALocalizedString(@"download_persian_voice_alert_title") details:details duration:4 inView:OARootViewController.instance.view]; }); } - NSLog(@"[OATTSCommandPlayerImpl] Invalid or unsupported locale identifier: %@, using current system language", voiceProvider); + OALog(@"[OATTSCommandPlayerImpl] Invalid or unsupported locale identifier: %@, using current system language", voiceProvider); return [AVSpeechSynthesisVoice voiceWithLanguage:[AVSpeechSynthesisVoice currentLanguageCode]]; } }