diff --git a/Gemfile.lock b/Gemfile.lock index 13962cbeb..98539bd5f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,34 +1,33 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.5) + CFPropertyList (3.0.6) rexml - activesupport (6.1.7) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.1) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) - arkana (1.3.0) - colorize (~> 0.8) + arkana (1.5.0) dotenv (~> 2.7) + rainbow (~> 3.1.1) yaml (~> 0.2) atomos (0.1.3) claide (1.1.0) - cocoapods (1.11.3) + cocoapods (1.12.1) addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.11.3) + cocoapods-core (= 1.12.1) cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 1.4.0, < 2.0) + cocoapods-downloader (>= 1.6.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-trunk (>= 1.6.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) @@ -36,11 +35,11 @@ GEM gh_inspector (~> 1.0) molinillo (~> 0.8.0) nap (~> 1.0) - ruby-macho (>= 1.0, < 3.0) + ruby-macho (>= 2.3.0, < 3.0) xcodeproj (>= 1.21.0, < 2.0) cocoapods-clean (0.0.1) - cocoapods-core (1.11.3) - activesupport (>= 5.0, < 7) + cocoapods-core (1.12.1) + activesupport (>= 5.0, < 8) addressable (~> 2.8) algoliasearch (~> 1.0) concurrent-ruby (~> 1.1) @@ -59,8 +58,7 @@ GEM netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) - colorize (0.8.1) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.2) dotenv (2.8.1) escape (0.0.4) ethon (0.16.0) @@ -70,21 +68,22 @@ GEM fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.12.0) + i18n (1.14.1) concurrent-ruby (~> 1.0) - json (2.6.2) - minitest (5.16.3) + json (2.6.3) + minitest (5.20.0) molinillo (0.8.0) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) public_suffix (4.0.7) - rexml (3.2.5) + rainbow (3.1.1) + rexml (3.2.6) rouge (2.0.7) ruby-macho (2.5.1) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) xcodeproj (1.22.0) CFPropertyList (>= 2.3.3, < 4.0) @@ -95,8 +94,7 @@ GEM rexml (~> 3.2.4) xcpretty (0.3.0) rouge (~> 2.0.7) - yaml (0.2.0) - zeitwerk (2.6.6) + yaml (0.2.1) PLATFORMS arm64-darwin-21 @@ -111,4 +109,4 @@ DEPENDENCIES xcpretty BUNDLED WITH - 2.3.26 + 2.4.6 diff --git a/Localization/StringsConvertor/Sources/StringsConvertor/main.swift b/Localization/StringsConvertor/Sources/StringsConvertor/main.swift index 65d2bb457..061448826 100644 --- a/Localization/StringsConvertor/Sources/StringsConvertor/main.swift +++ b/Localization/StringsConvertor/Sources/StringsConvertor/main.swift @@ -1,4 +1,3 @@ -import os.log import Foundation // conver i18n JSON templates to strings files @@ -12,15 +11,13 @@ private func convert(from inputDirectoryURL: URL, to outputDirectory: URL) { for inputLanguageDirectoryURL in inputLanguageDirectoryURLs { let language = inputLanguageDirectoryURL.lastPathComponent guard let mappedLanguage = map(language: language) else { continue } - os_log("%{public}s[%{public}ld], %{public}s: process %s -> %s", ((#file as NSString).lastPathComponent), #line, #function, language, mappedLanguage) - + let fileURLs = try FileManager.default.contentsOfDirectory( at: inputLanguageDirectoryURL, includingPropertiesForKeys: [.nameKey, .isDirectoryKey], options: [] ) for jsonURL in fileURLs where jsonURL.pathExtension == "json" { - os_log("%{public}s[%{public}ld], %{public}s: process %s", ((#file as NSString).lastPathComponent), #line, #function, jsonURL.debugDescription) let filename = jsonURL.deletingPathExtension().lastPathComponent guard let (mappedFilename, keyStyle) = map(filename: filename) else { continue } guard let bundle = bundle(filename: filename) else { continue } @@ -40,7 +37,6 @@ private func convert(from inputDirectoryURL: URL, to outputDirectory: URL) { } } } catch { - os_log("%{public}s[%{public}ld], %{public}s: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) exit(1) } } @@ -103,7 +99,6 @@ private func process(url: URL, keyStyle: Parser.KeyStyle) throws -> String { let strings = parser.generateStrings(keyStyle: keyStyle) return strings } catch { - os_log("%{public}s[%{public}ld], %{public}s: error: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) throw error } } @@ -120,15 +115,13 @@ private func move(from inputDirectoryURL: URL, to outputDirectoryURL: URL, pathE let language = inputLanguageDirectoryURL.lastPathComponent guard let mappedLanguage = map(language: language) else { continue } let outputDirectoryURL = outputDirectoryURL.appendingPathComponent(mappedLanguage + ".lproj", isDirectory: true) - os_log("%{public}s[%{public}ld], %{public}s: process %s -> %s", ((#file as NSString).lastPathComponent), #line, #function, language, mappedLanguage) - + let fileURLs = try FileManager.default.contentsOfDirectory( at: inputLanguageDirectoryURL, includingPropertiesForKeys: [.nameKey, .isDirectoryKey], options: [] ) for dictURL in fileURLs where dictURL.pathExtension == pathExtension { - os_log("%{public}s[%{public}ld], %{public}s: process %s", ((#file as NSString).lastPathComponent), #line, #function, dictURL.debugDescription) let filename = dictURL.deletingPathExtension().lastPathComponent let outputFileURL = outputDirectoryURL.appendingPathComponent(filename).appendingPathExtension(pathExtension) @@ -137,7 +130,6 @@ private func move(from inputDirectoryURL: URL, to outputDirectoryURL: URL, pathE } } } catch { - os_log("%{public}s[%{public}ld], %{public}s: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) exit(2) } } diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 628637c60..53d2f0e2b 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -79,7 +79,6 @@ 2D5981A125E4A593000FB903 /* MastodonConfirmEmailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D5981A025E4A593000FB903 /* MastodonConfirmEmailViewModel.swift */; }; 2D5A3D2825CF8BC9002347D6 /* HomeTimelineViewModel+Diffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D5A3D2725CF8BC9002347D6 /* HomeTimelineViewModel+Diffable.swift */; }; 2D5A3D3825CF8D9F002347D6 /* ScrollViewContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D5A3D3725CF8D9F002347D6 /* ScrollViewContainer.swift */; }; - 2D5A3D6225CFD9CB002347D6 /* HomeTimelineViewController+DebugAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D5A3D6125CFD9CB002347D6 /* HomeTimelineViewController+DebugAction.swift */; }; 2D607AD826242FC500B70763 /* NotificationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D607AD726242FC500B70763 /* NotificationViewModel.swift */; }; 2D694A7425F9EB4E0038ADDC /* ContentWarningOverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D694A7325F9EB4E0038ADDC /* ContentWarningOverlayView.swift */; }; 2D6DE40026141DF600A63F6A /* SearchViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D6DE3FF26141DF600A63F6A /* SearchViewModel.swift */; }; @@ -159,7 +158,6 @@ D8F8A03C29CA5CB6000195DD /* HashtagWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F8A03B29CA5CB6000195DD /* HashtagWidget.swift */; }; DB0009A626AEE5DC009B9D2D /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = DB0009A926AEE5DC009B9D2D /* Intents.intentdefinition */; settings = {ATTRIBUTES = (codegen, ); }; }; DB0009A726AEE5DC009B9D2D /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = DB0009A926AEE5DC009B9D2D /* Intents.intentdefinition */; }; - DB0140CF25C42AEE00F9F3CF /* OSLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0140CE25C42AEE00F9F3CF /* OSLog.swift */; }; DB023D26279FFB0A005AC798 /* ShareActivityProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB023D25279FFB0A005AC798 /* ShareActivityProvider.swift */; }; DB023D2827A0FABD005AC798 /* NotificationTableViewCellDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB023D2727A0FABD005AC798 /* NotificationTableViewCellDelegate.swift */; }; DB023D2A27A0FE5C005AC798 /* DataSourceProvider+NotificationTableViewCellDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB023D2927A0FE5C005AC798 /* DataSourceProvider+NotificationTableViewCellDelegate.swift */; }; @@ -693,7 +691,6 @@ 2D5981A025E4A593000FB903 /* MastodonConfirmEmailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonConfirmEmailViewModel.swift; sourceTree = ""; }; 2D5A3D2725CF8BC9002347D6 /* HomeTimelineViewModel+Diffable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HomeTimelineViewModel+Diffable.swift"; sourceTree = ""; }; 2D5A3D3725CF8D9F002347D6 /* ScrollViewContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollViewContainer.swift; sourceTree = ""; }; - 2D5A3D6125CFD9CB002347D6 /* HomeTimelineViewController+DebugAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HomeTimelineViewController+DebugAction.swift"; sourceTree = ""; }; 2D607AD726242FC500B70763 /* NotificationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewModel.swift; sourceTree = ""; }; 2D694A7325F9EB4E0038ADDC /* ContentWarningOverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentWarningOverlayView.swift; sourceTree = ""; }; 2D6DE3FF26141DF600A63F6A /* SearchViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewModel.swift; sourceTree = ""; }; @@ -810,7 +807,6 @@ D8F8A03B29CA5CB6000195DD /* HashtagWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagWidget.swift; sourceTree = ""; }; DB0009A826AEE5DC009B9D2D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; name = Base; path = Base.lproj/Intents.intentdefinition; sourceTree = ""; }; DB0009AD26AEE5E4009B9D2D /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Intents.strings; sourceTree = ""; }; - DB0140CE25C42AEE00F9F3CF /* OSLog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSLog.swift; sourceTree = ""; }; DB023D25279FFB0A005AC798 /* ShareActivityProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareActivityProvider.swift; sourceTree = ""; }; DB023D2727A0FABD005AC798 /* NotificationTableViewCellDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationTableViewCellDelegate.swift; sourceTree = ""; }; DB023D2927A0FE5C005AC798 /* DataSourceProvider+NotificationTableViewCellDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceProvider+NotificationTableViewCellDelegate.swift"; sourceTree = ""; }; @@ -1552,7 +1548,6 @@ DB1F239626117C360057430E /* View */, 2D38F1D425CD465300561493 /* HomeTimelineViewController.swift */, DB697DD8278F4CED004EF2F7 /* HomeTimelineViewController+DataSourceProvider.swift */, - 2D5A3D6125CFD9CB002347D6 /* HomeTimelineViewController+DebugAction.swift */, 2D38F1E425CD46C100561493 /* HomeTimelineViewModel.swift */, 2D5A3D2725CF8BC9002347D6 /* HomeTimelineViewModel+Diffable.swift */, 2D38F1EA25CD477000561493 /* HomeTimelineViewModel+LoadLatestState.swift */, @@ -2525,7 +2520,6 @@ 2D206B8525F5FB0900143C56 /* Double.swift */, DBB3BA2926A81C020004F2D4 /* FLAnimatedImageView.swift */, DB68586325E619B700F0A850 /* NSKeyValueObservation.swift */, - DB0140CE25C42AEE00F9F3CF /* OSLog.swift */, 2D939AB425EDD8A90076FA61 /* String.swift */, DB68A06225E905E000CFDF14 /* UIApplication.swift */, DB45FAB525CA5485005A8AC7 /* UIAlertController.swift */, @@ -3818,7 +3812,6 @@ D87BFC8B291D5C6B00FEE264 /* MastodonLoginView.swift in Sources */, DB6180F826391D660018D199 /* MediaPreviewingViewController.swift in Sources */, DBEFCD71282A12B200C0ABEA /* ReportReasonViewController.swift in Sources */, - DB0140CF25C42AEE00F9F3CF /* OSLog.swift in Sources */, DB98EB5627B0FF1B0082E365 /* ReportViewControllerAppearance.swift in Sources */, DB3EA8E6281B79E200598866 /* DiscoveryCommunityViewController.swift in Sources */, 2D206B8625F5FB0900143C56 /* Double.swift in Sources */, @@ -3890,7 +3883,6 @@ 2A82294F29262EE000D2A1F7 /* AppContext+NextAccount.swift in Sources */, DBB525302611EBF3002F1F29 /* ProfilePagingViewModel.swift in Sources */, DB9F58EC26EF435000E7BBE9 /* AccountViewController.swift in Sources */, - 2D5A3D6225CFD9CB002347D6 /* HomeTimelineViewController+DebugAction.swift in Sources */, DB3E6FF12806D96900B035AE /* DiscoveryNewsViewModel+Diffable.swift in Sources */, DB3E6FF82807C45300B035AE /* DiscoveryForYouViewModel.swift in Sources */, DB0F9D56283EB46200379AF8 /* ProfileHeaderView+Configuration.swift in Sources */, @@ -4584,7 +4576,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2023.13; + MARKETING_VERSION = 2023.14; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -4616,7 +4608,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2023.13; + MARKETING_VERSION = 2023.14; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -4803,7 +4795,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2023.13; + MARKETING_VERSION = 2023.14; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -5094,7 +5086,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2023.13; + MARKETING_VERSION = 2023.14; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved index 232ec9c87..c6e38eff3 100644 --- a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -19,15 +19,6 @@ "version": "4.2.0" } }, - { - "package": "CommonOSLog", - "repositoryURL": "https://github.com/MainasuK/CommonOSLog", - "state": { - "branch": null, - "revision": "c121624a30698e9886efe38aebb36ff51c01b6c2", - "version": "0.1.1" - } - }, { "package": "FaviconFinder", "repositoryURL": "https://github.com/will-lumley/FaviconFinder.git", @@ -46,15 +37,6 @@ "version": "1.0.17" } }, - { - "package": "FPSIndicator", - "repositoryURL": "https://github.com/MainasuK/FPSIndicator.git", - "state": { - "branch": null, - "revision": "e4a5067ccd5293b024c767f09e51056afd4a4796", - "version": "1.1.0" - } - }, { "package": "Fuzi", "repositoryURL": "https://github.com/cezheng/Fuzi.git", @@ -154,6 +136,15 @@ "version": "0.2.0" } }, + { + "package": "swift-atomics", + "repositoryURL": "https://github.com/apple/swift-atomics.git", + "state": { + "branch": null, + "revision": "6c89474e62719ddcc1e9614989fff2f68208fe10", + "version": "1.1.0" + } + }, { "package": "swift-collections", "repositoryURL": "https://github.com/apple/swift-collections.git", @@ -168,17 +159,8 @@ "repositoryURL": "https://github.com/apple/swift-nio.git", "state": { "branch": null, - "revision": "546610d52b19be3e19935e0880bb06b9c03f5cef", - "version": "1.14.4" - } - }, - { - "package": "swift-nio-zlib-support", - "repositoryURL": "https://github.com/apple/swift-nio-zlib-support.git", - "state": { - "branch": null, - "revision": "37760e9a52030bb9011972c5213c3350fa9d41fd", - "version": "1.0.0" + "revision": "3db5c4aeee8100d2db6f1eaf3864afdad5dc68fd", + "version": "2.59.0" } }, { @@ -190,15 +172,6 @@ "version": "2.4.3" } }, - { - "package": "Introspect", - "repositoryURL": "https://github.com/siteline/SwiftUI-Introspect.git", - "state": { - "branch": null, - "revision": "f2616860a41f9d9932da412a8978fec79c06fe24", - "version": "0.1.4" - } - }, { "package": "TabBarPager", "repositoryURL": "https://github.com/TwidereProject/TabBarPager.git", diff --git a/Mastodon/Diffable/Discovery/DiscoverySection.swift b/Mastodon/Diffable/Discovery/DiscoverySection.swift index 53726292b..bb93ffc28 100644 --- a/Mastodon/Diffable/Discovery/DiscoverySection.swift +++ b/Mastodon/Diffable/Discovery/DiscoverySection.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-13. // -import os.log import UIKit import MastodonCore import MastodonUI @@ -20,8 +19,6 @@ enum DiscoverySection: CaseIterable { extension DiscoverySection { - static let logger = Logger(subsystem: "DiscoverySection", category: "logic") - class Configuration { let authContext: AuthContext weak var profileCardTableViewCellDelegate: ProfileCardTableViewCellDelegate? diff --git a/Mastodon/Diffable/Report/ReportSection.swift b/Mastodon/Diffable/Report/ReportSection.swift index 4c8fd4345..99e04ea1f 100644 --- a/Mastodon/Diffable/Report/ReportSection.swift +++ b/Mastodon/Diffable/Report/ReportSection.swift @@ -11,7 +11,6 @@ import CoreDataStack import Foundation import MastodonSDK import UIKit -import os.log import MastodonAsset import MastodonCore import MastodonUI diff --git a/Mastodon/Diffable/Status/StatusSection.swift b/Mastodon/Diffable/Status/StatusSection.swift index e134a17cb..586764f42 100644 --- a/Mastodon/Diffable/Status/StatusSection.swift +++ b/Mastodon/Diffable/Status/StatusSection.swift @@ -8,7 +8,6 @@ import Combine import CoreData import CoreDataStack -import os.log import UIKit import AVKit import AlamofireImage @@ -24,8 +23,6 @@ enum StatusSection: Equatable, Hashable { extension StatusSection { - static let logger = Logger(subsystem: "StatusSection", category: "logic") - struct Configuration { let context: AppContext let authContext: AuthContext @@ -196,7 +193,6 @@ extension StatusSection { else { return false } guard !poll.expired else { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): poll expired. Skip update poll \(poll.id)") return false } @@ -209,10 +205,9 @@ extension StatusSection { #endif guard timeIntervalSinceUpdate > autoRefreshTimeInterval else { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): skip update poll \(poll.id) due to recent updated") return false } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update poll \(poll.id)…") + return true }() diff --git a/Mastodon/Diffable/User/UserSection.swift b/Mastodon/Diffable/User/UserSection.swift index 4189829e4..e6632c337 100644 --- a/Mastodon/Diffable/User/UserSection.swift +++ b/Mastodon/Diffable/User/UserSection.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-11-1. // -import os.log import UIKit import CoreData import CoreDataStack @@ -20,9 +19,6 @@ enum UserSection: Hashable { } extension UserSection { - - static let logger = Logger(subsystem: "StatusSection", category: "logic") - struct Configuration { weak var userTableViewCellDelegate: UserTableViewCellDelegate? } diff --git a/Mastodon/Extension/OSLog.swift b/Mastodon/Extension/OSLog.swift deleted file mode 100644 index 0121200d9..000000000 --- a/Mastodon/Extension/OSLog.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// OSLog.swift -// Mastodon -// -// Created by Cirno MainasuK on 2021/1/29 -// - -import os -import Foundation -import CommonOSLog - -extension OSLog { - static let api: OSLog = { - #if DEBUG - return OSLog(subsystem: OSLog.subsystem + ".api", category: "api") - #else - return OSLog.disabled - #endif - }() -} diff --git a/Mastodon/Protocol/Provider/DataSourceFacade+Media.swift b/Mastodon/Protocol/Provider/DataSourceFacade+Media.swift index 9dd97f38a..8379f08e9 100644 --- a/Mastodon/Protocol/Provider/DataSourceFacade+Media.swift +++ b/Mastodon/Protocol/Provider/DataSourceFacade+Media.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-26. // -import os.log import UIKit import CoreDataStack import MastodonUI @@ -154,8 +153,6 @@ extension DataSourceFacade { user: ManagedObjectRecord, previewContext: ImagePreviewContext ) async throws { - let logger = Logger(subsystem: "DataSourceFacade", category: "Media") - let managedObjectContext = dependency.context.managedObjectContext var _avatarAssetURL: String? @@ -227,7 +224,6 @@ extension DataSourceFacade { }() guard mediaPreviewItem.isAssetURLValid else { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): discard preview due to assetURL invalid") return } diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewControllerNavigateable.swift b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewControllerNavigateable.swift index b8cf026d4..f90827863 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewControllerNavigateable.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewControllerNavigateable.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-2-16. // -import os.log import UIKit import CoreDataStack import MastodonCore @@ -37,7 +36,6 @@ extension StatusTableViewControllerNavigateableCore where Self: DataSourceProvid guard let rawValue = sender.propertyList as? String, let navigation = StatusTableViewNavigation(rawValue: rawValue) else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: %s", ((#file as NSString).lastPathComponent), #line, #function, navigation.title) Task { switch navigation { case .openAuthorProfile: await openAuthorProfile(target: .status) diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+TableViewControllerNavigateable.swift b/Mastodon/Protocol/Provider/DataSourceProvider+TableViewControllerNavigateable.swift index 35ef7761e..6292d4b22 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+TableViewControllerNavigateable.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+TableViewControllerNavigateable.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-2-16. // -import os.log import UIKit import MastodonCore @@ -34,7 +33,6 @@ extension TableViewControllerNavigateableCore { guard let rawValue = sender.propertyList as? String, let navigation = TableViewNavigation(rawValue: rawValue) else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: %s", ((#file as NSString).lastPathComponent), #line, #function, navigation.title) switch navigation { case .up: navigate(direction: .up) case .down: navigate(direction: .down) diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+UITableViewDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+UITableViewDelegate.swift index 299951ce2..611223df8 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+UITableViewDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+UITableViewDelegate.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-17. // -import os.log import UIKit import CoreDataStack import MastodonCore @@ -126,7 +125,6 @@ extension UITableViewDelegate where Self: DataSourceProvider & MediaPreviewableV attributes: [], state: .off ) { [weak self] _ in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: save photo", ((#file as NSString).lastPathComponent), #line, #function) guard let self = self else { return } Task { @MainActor in do { @@ -157,7 +155,6 @@ extension UITableViewDelegate where Self: DataSourceProvider & MediaPreviewableV attributes: [], state: .off ) { [weak self] _ in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: copy photo", ((#file as NSString).lastPathComponent), #line, #function) guard let self = self else { return } Task { try await self.context.photoLibraryService.copy( @@ -173,7 +170,6 @@ extension UITableViewDelegate where Self: DataSourceProvider & MediaPreviewableV attributes: [], state: .off ) { [weak self] _ in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: share", ((#file as NSString).lastPathComponent), #line, #function) guard let self = self else { return } Task { let applicationActivities: [UIActivity] = [ diff --git a/Mastodon/Protocol/Provider/DataSourceProvider.swift b/Mastodon/Protocol/Provider/DataSourceProvider.swift index e4287b6b9..6df47ccae 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider.swift @@ -6,7 +6,6 @@ // Copyright © 2021 Twidere. All rights reserved. // -import os.log import UIKit import CoreDataStack import MastodonSDK diff --git a/Mastodon/Protocol/StatusTableViewControllerNavigateable.swift b/Mastodon/Protocol/StatusTableViewControllerNavigateable.swift index a35fae7b7..6539137a5 100644 --- a/Mastodon/Protocol/StatusTableViewControllerNavigateable.swift +++ b/Mastodon/Protocol/StatusTableViewControllerNavigateable.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-5-19. // -import os.log import UIKit import MastodonAsset import MastodonLocalization diff --git a/Mastodon/Protocol/TableViewControllerNavigateable.swift b/Mastodon/Protocol/TableViewControllerNavigateable.swift index 4189d0cfc..5a96e74ff 100644 --- a/Mastodon/Protocol/TableViewControllerNavigateable.swift +++ b/Mastodon/Protocol/TableViewControllerNavigateable.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-5-21. // -import os.log import UIKit import MastodonAsset import MastodonLocalization diff --git a/Mastodon/Scene/Account/AccountListViewModel.swift b/Mastodon/Scene/Account/AccountListViewModel.swift index be09d376e..5919596bf 100644 --- a/Mastodon/Scene/Account/AccountListViewModel.swift +++ b/Mastodon/Scene/Account/AccountListViewModel.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-9-13. // -import os.log import UIKit import Combine import CoreData diff --git a/Mastodon/Scene/Account/AccountViewController.swift b/Mastodon/Scene/Account/AccountViewController.swift index 4eab3565c..5289dfeb4 100644 --- a/Mastodon/Scene/Account/AccountViewController.swift +++ b/Mastodon/Scene/Account/AccountViewController.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-9-13. // -import os.log import UIKit import Combine import CoreDataStack @@ -16,8 +15,6 @@ import MastodonCore final class AccountListViewController: UIViewController, NeedsDependency { - let logger = Logger(subsystem: "AccountListViewController", category: "UI") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -153,12 +150,10 @@ extension AccountListViewController { extension AccountListViewController { @objc private func addBarButtonItem(_ sender: UIBarButtonItem) { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") _ = coordinator.present(scene: .welcome, from: self, transition: .modal(animated: true, completion: nil)) } override func accessibilityPerformEscape() -> Bool { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") dismiss(animated: true, completion: nil) return true } diff --git a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusAttachmentCollectionViewCell.swift b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusAttachmentCollectionViewCell.swift index 046247507..d7bfe9928 100644 --- a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusAttachmentCollectionViewCell.swift +++ b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusAttachmentCollectionViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-17. // -import os.log import UIKit import Combine import MastodonUI @@ -18,8 +17,6 @@ protocol ComposeStatusAttachmentCollectionViewCellDelegate: AnyObject { final class ComposeStatusAttachmentCollectionViewCell: UICollectionViewCell { - let logger = Logger(subsystem: "ComposeStatusAttachmentCollectionViewCell", category: "UI") - var disposeBag = Set() static let verticalMarginHeight: CGFloat = ComposeStatusAttachmentCollectionViewCell.removeButtonSize.height * 0.5 @@ -45,62 +42,21 @@ final class ComposeStatusAttachmentCollectionViewCell: UICollectionViewCell { override func prepareForReuse() { super.prepareForReuse() -// attachmentContainerView.activityIndicatorView.startAnimating() -// attachmentContainerView.previewImageView.af.cancelImageRequest() -// attachmentContainerView.previewImageView.image = .placeholder(color: .systemFill) -// delegate = nil -// disposeBag.removeAll() } override init(frame: CGRect) { super.init(frame: frame) - _init() } required init?(coder: NSCoder) { super.init(coder: coder) - _init() } - deinit { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - } - -} - -extension ComposeStatusAttachmentCollectionViewCell { - - private func _init() { - // selectionStyle = .none - -// attachmentContainerView.translatesAutoresizingMaskIntoConstraints = false -// contentView.addSubview(attachmentContainerView) -// NSLayoutConstraint.activate([ -// attachmentContainerView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: ComposeStatusAttachmentCollectionViewCell.verticalMarginHeight), -// attachmentContainerView.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor), -// attachmentContainerView.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor), -// contentView.bottomAnchor.constraint(equalTo: attachmentContainerView.bottomAnchor, constant: ComposeStatusAttachmentCollectionViewCell.verticalMarginHeight), -// attachmentContainerView.heightAnchor.constraint(equalToConstant: 205).priority(.defaultHigh), -// ]) -// -// removeButton.translatesAutoresizingMaskIntoConstraints = false -// contentView.addSubview(removeButton) -// NSLayoutConstraint.activate([ -// removeButton.centerXAnchor.constraint(equalTo: attachmentContainerView.trailingAnchor), -// removeButton.centerYAnchor.constraint(equalTo: attachmentContainerView.topAnchor), -// removeButton.widthAnchor.constraint(equalToConstant: ComposeStatusAttachmentCollectionViewCell.removeButtonSize.width).priority(.defaultHigh), -// removeButton.heightAnchor.constraint(equalToConstant: ComposeStatusAttachmentCollectionViewCell.removeButtonSize.height).priority(.defaultHigh), -// ]) -// -// removeButton.addTarget(self, action: #selector(ComposeStatusAttachmentCollectionViewCell.removeButtonDidPressed(_:)), for: .touchUpInside) - } - } extension ComposeStatusAttachmentCollectionViewCell { @objc private func removeButtonDidPressed(_ sender: UIButton) { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") delegate?.composeStatusAttachmentCollectionViewCell(self, removeButtonDidPressed: sender) } diff --git a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionAppendEntryCollectionViewCell.swift b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionAppendEntryCollectionViewCell.swift index d160ef7f5..e597fca45 100644 --- a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionAppendEntryCollectionViewCell.swift +++ b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionAppendEntryCollectionViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-23. // -import os.log import UIKit import MastodonAsset import MastodonCore @@ -111,7 +110,6 @@ extension ComposeStatusPollOptionAppendEntryCollectionViewCell { extension ComposeStatusPollOptionAppendEntryCollectionViewCell { @objc private func singleTagGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.composeStatusPollOptionAppendEntryCollectionViewCellDidPressed(self) } diff --git a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionCollectionViewCell.swift b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionCollectionViewCell.swift index 96ba4ce59..2bdf49707 100644 --- a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionCollectionViewCell.swift +++ b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionCollectionViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-23. // -import os.log import UIKit import Combine import MastodonAsset @@ -127,7 +126,6 @@ extension ComposeStatusPollOptionCollectionViewCell { extension ComposeStatusPollOptionCollectionViewCell { @objc private func singleTagGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) pollOptionView.optionTextField.becomeFirstResponder() } @@ -144,12 +142,10 @@ extension ComposeStatusPollOptionCollectionViewCell: DeleteBackwardResponseTextF extension ComposeStatusPollOptionCollectionViewCell: UITextFieldDelegate { func textFieldDidBeginEditing(_ textField: UITextField) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.composeStatusPollOptionCollectionViewCell(self, textFieldDidBeginEditing: textField) } func textFieldShouldReturn(_ textField: UITextField) -> Bool { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) if textField === pollOptionView.optionTextField { delegate?.composeStatusPollOptionCollectionViewCell(self, pollOptionTextFieldDidReturn: textField) } diff --git a/Mastodon/Scene/Compose/ComposeViewController.swift b/Mastodon/Scene/Compose/ComposeViewController.swift index 23cf1768b..71c797a9c 100644 --- a/Mastodon/Scene/Compose/ComposeViewController.swift +++ b/Mastodon/Scene/Compose/ComposeViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-11. // -import os.log import UIKit import Combine import PhotosUI @@ -25,9 +24,7 @@ final class ComposeViewController: UIViewController, NeedsDependency { weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } var disposeBag = Set() - var viewModel: ComposeViewModel! - - let logger = Logger(subsystem: "ComposeViewController", category: "logic") + var viewModel: ComposeViewModel init(viewModel: ComposeViewModel) { self.viewModel = viewModel @@ -114,9 +111,6 @@ final class ComposeViewController: UIViewController, NeedsDependency { button.setTitleColor(Asset.Colors.Label.primaryReverse.color, for: .normal) } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -202,7 +196,6 @@ extension ComposeViewController { extension ComposeViewController { @objc private func cancelBarButtonItemPressed(_ sender: UIBarButtonItem) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") guard composeContentViewModel.shouldDismiss else { showDismissConfirmAlertController() return @@ -282,11 +275,9 @@ extension ComposeViewController { } override func paste(_ sender: Any?) { - logger.debug("Paste event received") // Look for images on the clipboard if UIPasteboard.general.hasImages, let images = UIPasteboard.general.images { - logger.warning("Got image paste event, however attachments are not yet re-implemented."); let attachmentViewModels = images.map { image in return AttachmentViewModel( api: viewModel.context.apiService, @@ -318,14 +309,8 @@ extension ComposeViewController: UIAdaptivePresentationControllerDelegate { } func presentationControllerDidAttemptToDismiss(_ presentationController: UIPresentationController) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) showDismissConfirmAlertController() } - - func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension ComposeViewController { diff --git a/Mastodon/Scene/Compose/ComposeViewModel.swift b/Mastodon/Scene/Compose/ComposeViewModel.swift index 8992ac7a6..442a47de4 100644 --- a/Mastodon/Scene/Compose/ComposeViewModel.swift +++ b/Mastodon/Scene/Compose/ComposeViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-11. // -import os.log import UIKit import Combine import CoreData @@ -24,8 +23,6 @@ final class ComposeViewModel { case composeStatus case editStatus(status: Status, statusSource: Mastodon.Entity.StatusSource) } - - let logger = Logger(subsystem: "ComposeViewModel", category: "ViewModel") var disposeBag = Set() diff --git a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift index 0ef14b4ca..6e28bbd18 100644 --- a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift +++ b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-29. // -import os.log import UIKit import Combine import MastodonCore @@ -13,9 +12,6 @@ import MastodonUI // Local Timeline final class DiscoveryCommunityViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - - let logger = Logger(subsystem: "DiscoveryCommunityViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } diff --git a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewModel.swift b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewModel.swift index 5e98a1ba2..6169e0830 100644 --- a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewModel.swift +++ b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-29. // -import os.log import UIKit import Combine import GameplayKit diff --git a/Mastodon/Scene/Discovery/DiscoveryViewController.swift b/Mastodon/Scene/Discovery/DiscoveryViewController.swift index 969ba5534..027f1c216 100644 --- a/Mastodon/Scene/Discovery/DiscoveryViewController.swift +++ b/Mastodon/Scene/Discovery/DiscoveryViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-12. // -import os.log import UIKit import Combine import Tabman @@ -21,8 +20,6 @@ public class DiscoveryViewController: TabmanViewController, NeedsDependency { var disposeBag = Set() - let logger = Logger(subsystem: "DiscoveryViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } diff --git a/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift b/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift index 64d1231fe..304ea0e1c 100644 --- a/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift +++ b/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-13. // -import os.log import UIKit import Combine import MastodonCore @@ -13,8 +12,6 @@ import MastodonUI final class DiscoveryHashtagsViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - let logger = Logger(subsystem: "TrendPostsViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -34,9 +31,6 @@ final class DiscoveryHashtagsViewController: UIViewController, NeedsDependency, let refreshControl = RefreshControl() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -100,7 +94,6 @@ extension DiscoveryHashtagsViewController { extension DiscoveryHashtagsViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(indexPath)") guard case let .hashtag(tag) = viewModel.diffableDataSource?.itemIdentifier(for: indexPath) else { return } let hashtagTimelineViewModel = HashtagTimelineViewModel(context: context, authContext: viewModel.authContext, hashtag: tag.name) _ = coordinator.present( diff --git a/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewModel.swift b/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewModel.swift index a4c4d7814..d45b711e9 100644 --- a/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewModel.swift +++ b/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-13. // -import os.log import UIKit import Combine import GameplayKit diff --git a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift index 4884aafac..0d4331ddc 100644 --- a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift +++ b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-13. // -import os.log import UIKit import Combine import MastodonCore @@ -13,8 +12,6 @@ import MastodonUI final class DiscoveryNewsViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - let logger = Logger(subsystem: "TrendPostsViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -33,11 +30,6 @@ final class DiscoveryNewsViewController: UIViewController, NeedsDependency, Medi }() let refreshControl = RefreshControl() - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension DiscoveryNewsViewController { @@ -109,7 +101,6 @@ extension DiscoveryNewsViewController { extension DiscoveryNewsViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(indexPath)") guard case let .link(link) = viewModel.diffableDataSource?.itemIdentifier(for: indexPath) else { return } guard let url = URL(string: link.url) else { return } _ = coordinator.present( diff --git a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel+State.swift b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel+State.swift index adc8a786e..86f450781 100644 --- a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel+State.swift +++ b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel+State.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-13. // -import os.log import Foundation import GameplayKit import MastodonSDK @@ -13,8 +12,6 @@ import MastodonSDK extension DiscoveryNewsViewModel { class State: GKState { - let logger = Logger(subsystem: "DiscoveryNewsViewModel.State", category: "StateMachine") - let id = UUID() weak var viewModel: DiscoveryNewsViewModel? @@ -23,14 +20,6 @@ extension DiscoveryNewsViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel.swift b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel.swift index 7e6bcbde5..52061d5ae 100644 --- a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel.swift +++ b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-13. // -import os.log import UIKit import Combine import GameplayKit diff --git a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift index 01b4f7ba8..6e1aa124d 100644 --- a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift +++ b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift @@ -5,16 +5,12 @@ // Created by MainasuK on 2022-4-12. // -import os.log import UIKit import Combine import MastodonCore import MastodonUI final class DiscoveryPostsViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - - let logger = Logger(subsystem: "TrendPostsViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } diff --git a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+State.swift b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+State.swift index 7585e5387..75794258d 100644 --- a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+State.swift +++ b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+State.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-12. // -import os.log import Foundation import GameplayKit import MastodonSDK @@ -13,9 +12,6 @@ import MastodonCore extension DiscoveryPostsViewModel { class State: GKState { - - let logger = Logger(subsystem: "DiscoveryPostsViewModel.State", category: "StateMachine") - let id = UUID() weak var viewModel: DiscoveryPostsViewModel? @@ -24,22 +20,10 @@ extension DiscoveryPostsViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -88,9 +72,7 @@ extension DiscoveryPostsViewModel.State { super.didEnter(from: previousState) guard let _ = viewModel, let stateMachine = stateMachine else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading 3s later…", ((#file as NSString).lastPathComponent), #line, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading", ((#file as NSString).lastPathComponent), #line, #function) stateMachine.enter(Loading.self) } } diff --git a/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift b/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift index 492541062..65943d7d3 100644 --- a/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift +++ b/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-19. // -import os.log import UIKit import Combine import MastodonAsset @@ -18,9 +17,6 @@ public protocol DiscoveryIntroBannerViewDelegate: AnyObject { } public final class DiscoveryIntroBannerView: UIView { - - let logger = Logger(subsystem: "DiscoveryIntroBannerView", category: "View") - var _disposeBag = Set() public weak var delegate: DiscoveryIntroBannerViewDelegate? @@ -90,7 +86,6 @@ extension DiscoveryIntroBannerView { extension DiscoveryIntroBannerView { @objc private func closeButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") delegate?.discoveryIntroBannerView(self, closeButtonDidPressed: sender) } } diff --git a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift index c41b7b5f4..a387b99ea 100644 --- a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift +++ b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift @@ -5,7 +5,6 @@ // Created by BradGao on 2021/3/30. // -import os.log import UIKit import AVKit import Combine @@ -19,8 +18,6 @@ import MastodonSDK final class HashtagTimelineViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - let logger = Logger(subsystem: "HashtagTimelineViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -61,10 +58,6 @@ final class HashtagTimelineViewController: UIViewController, NeedsDependency, Me }() let refreshControl = RefreshControl() - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s:", ((#file as NSString).lastPathComponent), #line, #function) - } } extension HashtagTimelineViewController { @@ -205,7 +198,6 @@ extension HashtagTimelineViewController { } @objc private func composeBarButtonItemPressed(_ sender: UIBarButtonItem) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) let hashtag = "#" + viewModel.hashtag UITextChecker.learnWord(hashtag) let composeViewModel = ComposeViewModel( diff --git a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+Diffable.swift b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+Diffable.swift index c7c0a3bd7..8cc185382 100644 --- a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+Diffable.swift +++ b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+Diffable.swift @@ -5,7 +5,6 @@ // Created by BradGao on 2021/3/30. // -import os.log import UIKit import Combine import CoreData @@ -40,7 +39,6 @@ extension HashtagTimelineViewModel { .sink { [weak self] records in guard let self = self else { return } guard let diffableDataSource = self.diffableDataSource else { return } - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): incoming \(records.count) objects") var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([.main]) diff --git a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+State.swift b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+State.swift index c35715f1e..579060bda 100644 --- a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+State.swift +++ b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+State.swift @@ -5,7 +5,6 @@ // Created by BradGao on 2021/3/31. // -import os.log import Foundation import GameplayKit import CoreDataStack @@ -13,8 +12,6 @@ import CoreDataStack extension HashtagTimelineViewModel { class State: GKState { - let logger = Logger(subsystem: "HashtagTimelineViewModel.LoadOldestState", category: "StateMachine") - let id = UUID() var name: String { @@ -27,22 +24,10 @@ extension HashtagTimelineViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(self.name)") - } } } @@ -90,9 +75,7 @@ extension HashtagTimelineViewModel.State { super.didEnter(from: previousState) guard let _ = viewModel, let stateMachine = stateMachine else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading 3s later…", ((#file as NSString).lastPathComponent), #line, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading", ((#file as NSString).lastPathComponent), #line, #function) stateMachine.enter(Loading.self) } } @@ -178,7 +161,6 @@ extension HashtagTimelineViewModel.State { viewModel.fetchedResultsController.append(statusIDs: statusIDs) viewModel.didLoadLatest.send() } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch statues failed: \(error.localizedDescription)") await enter(state: Fail.self) } } // end Task diff --git a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel.swift b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel.swift index 888bc720c..fbdc42a1c 100644 --- a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel.swift +++ b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel.swift @@ -5,7 +5,6 @@ // Created by BradGao on 2021/3/30. // -import os.log import UIKit import Combine import CoreData @@ -15,9 +14,7 @@ import MastodonSDK import MastodonCore final class HashtagTimelineViewModel { - - let logger = Logger(subsystem: "HashtagTimelineViewModel", category: "ViewModel") - + let hashtag: String var disposeBag = Set() @@ -66,10 +63,6 @@ final class HashtagTimelineViewModel { // end init } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s:", ((#file as NSString).lastPathComponent), #line, #function) - } - func viewWillAppear() { let predicate = Tag.predicate( domain: authContext.mastodonAuthenticationBox.domain, diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController+DebugAction.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController+DebugAction.swift deleted file mode 100644 index 8ad798165..000000000 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController+DebugAction.swift +++ /dev/null @@ -1,451 +0,0 @@ -// -// HomeTimelineViewController+DebugAction.swift -// Mastodon -// -// Created by MainasuK Cirno on 2021-2-5. -// - - -#if DEBUG || SNAPSHOT -import os.log -import UIKit -import CoreData -import CoreDataStack -import FLEX -import SwiftUI -import MastodonCore -import MastodonUI -import MastodonSDK -import StoreKit - -extension HomeTimelineViewController { - var debugMenu: UIMenu { - let menu = UIMenu( - title: "Debug Tools", - image: nil, - identifier: nil, - options: .displayInline, - children: [ - showMenu, - moveMenu, - dropMenu, - miscMenu, - notificationMenu, - UIAction(title: "Settings", image: UIImage(systemName: "gear"), attributes: []) { [weak self] action in - guard let self = self else { return } - self.showSettings(action) - }, - UIAction(title: "Sign Out", image: UIImage(systemName: "escape"), attributes: .destructive) { [weak self] action in - guard let self = self else { return } - self.signOutAction(action) - } - ] - ) - return menu - } - - var showMenu: UIMenu { - return UIMenu( - title: "Show…", - image: UIImage(systemName: "plus.rectangle.on.rectangle"), - identifier: nil, - options: [], - children: [ - UIAction(title: "FLEX", image: nil, attributes: [], handler: { [weak self] action in - guard let self = self else { return } - self.showFLEXAction(action) - }), - UIAction(title: "Welcome", image: UIImage(systemName: "figure.walk"), attributes: []) { [weak self] action in - guard let self = self else { return } - self.showWelcomeAction(action) - }, - UIAction(title: "Register", image: UIImage(systemName: "list.bullet.rectangle.portrait.fill"), attributes: []) { [weak self] action in - guard let self = self else { return } - self.showRegisterAction(action) - }, - UIAction(title: "Confirm Email", image: UIImage(systemName: "envelope"), attributes: []) { [weak self] action in - guard let self = self else { return } - self.showConfirmEmail(action) - }, - UIAction(title: "Account List", image: UIImage(systemName: "person"), attributes: []) { [weak self] action in - guard let self = self else { return } - self.showAccountList(action) - }, - UIAction(title: "Profile", image: UIImage(systemName: "person.crop.circle"), attributes: []) { [weak self] action in - guard let self = self else { return } - self.showProfileAction(action) - }, - UIAction(title: "Thread", image: UIImage(systemName: "bubble.left.and.bubble.right"), attributes: []) { [weak self] action in - guard let self = self else { return } - self.showThreadAction(action) - }, - UIAction(title: "Account Recommend", image: UIImage(systemName: "human"), attributes: []) { [weak self] action in - guard let self = self else { return } - let suggestionAccountViewModel = SuggestionAccountViewModel( - context: self.context, - authContext: self.viewModel.authContext - ) - _ = self.coordinator.present( - scene: .suggestionAccount(viewModel: suggestionAccountViewModel), - from: self, - transition: .modal(animated: true, completion: nil) - ) - }, - UIAction(title: "Store Rating", image: UIImage(systemName: "star.fill"), attributes: []) { [weak self] action in - guard let self = self else { return } - guard let windowScene = self.view.window?.windowScene else { return } - SKStoreReviewController.requestReview(in: windowScene) - }, - ] - ) - } - - var dropMenu: UIMenu { - return UIMenu( - title: "Drop…", - image: UIImage(systemName: "minus.circle"), - identifier: nil, - options: [], - children: [50, 100, 150, 200, 250, 300].map { count in - UIAction(title: "Drop Recent \(count) Statuses", image: nil, attributes: [], handler: { [weak self] action in - guard let self = self else { return } - self.dropRecentStatusAction(action, count: count) - }) - } - ) - } - - var miscMenu: UIMenu { - return UIMenu( - title: "Debug…", - image: UIImage(systemName: "switch.2"), - identifier: nil, - options: [], - children: [ - UIAction(title: "Toggle Visible Touches", image: UIImage(systemName: "hand.tap"), attributes: []) { _ in - guard let window = UIApplication.shared.getKeyWindow() as? TouchesVisibleWindow else { return } - window.touchesVisible = !window.touchesVisible - }, - UIAction(title: "Toggle EmptyView", image: UIImage(systemName: "clear"), attributes: []) { [weak self] action in - guard let self = self else { return } - if self.emptyView.superview != nil { - self.emptyView.removeFromSuperview() - } else { - self.showEmptyView() - } - }, - UIAction( - title: "Enable account switcher wizard", - image: UIImage(systemName: "square.stack.3d.down.forward.fill"), - identifier: nil, - attributes: [], - state: .off, - handler: { _ in - UserDefaults.shared.didShowMultipleAccountSwitchWizard = false - } - ), - ] - ) - } - - var notificationMenu: UIMenu { - return UIMenu( - title: "Notification…", - image: UIImage(systemName: "bell.badge"), - identifier: nil, - options: [], - children: [ - UIAction(title: "Badge +1", image: UIImage(systemName: "app.badge.fill"), attributes: []) { [weak self] action in - guard let self = self else { return } - let accessToken = self.viewModel.authContext.mastodonAuthenticationBox.userAuthorization.accessToken - UserDefaults.shared.increaseNotificationCount(accessToken: accessToken) - self.context.notificationService.applicationIconBadgeNeedsUpdate.send() - }, - UIAction(title: "Profile", image: UIImage(systemName: "person.badge.plus"), attributes: []) { [weak self] action in - guard let self = self else { return } - self.showNotification(action, notificationType: .follow) - }, - UIAction(title: "Status", image: UIImage(systemName: "list.bullet.rectangle"), attributes: []) { [weak self] action in - guard let self = self else { return } - self.showNotification(action, notificationType: .mention) - }, - ] - ) - } - -} - -extension HomeTimelineViewController { - - enum MoveAction: String, CaseIterable { - case gap - case reply - case mention - case poll -// case quote -// case gif -// case video -// case location -// case followsYouAuthor -// case blockingAuthor - - var title: String { - return rawValue.capitalized - } - - func match(item: StatusItem) -> Bool { - // let authenticationBox = AppContext.shared.authenticationService.activeMastodonAuthenticationBox.value - switch item { - case .feed(let record): - guard let feed = record.object(in: AppContext.shared.managedObjectContext) else { return false } - if let status = feed.status { - switch self { - case .gap: - return false - case .reply: - return status.inReplyToID != nil - case .mention: - return !(status.reblog ?? status).mentions.isEmpty - case .poll: - return (status.reblog ?? status).poll != nil -// case .quote: -// return status.quote != nil -// case .gif: -// return status.attachments.contains(where: { attachment in attachment.kind == .animatedGIF }) -// case .video: -// return status.attachments.contains(where: { attachment in attachment.kind == .video }) -// case .location: -// return status.location != nil -// case .followsYouAuthor: -// guard case let .twitter(authenticationContext) = authenticationContext else { return false } -// guard let me = authenticationContext.authenticationRecord.object(in: AppContext.shared.managedObjectContext)?.user else { return false } -// return (status.repost ?? status).author.following.contains(me) -// case .blockingAuthor: -// guard case let .twitter(authenticationContext) = authenticationContext else { return false } -// guard let me = authenticationContext.authenticationRecord.object(in: AppContext.shared.managedObjectContext)?.user else { return false } -// return (status.repost ?? status).author.blockingBy.contains(me) -// default: -// return false - } // end switch - } else { - return false - } - case .feedLoader where self == .gap: - return true - default: - return false - } - } - - func firstMatch(in items: [StatusItem]) -> StatusItem? { - return items.first { item in self.match(item: item) } - } - } - - var moveMenu: UIMenu { - return UIMenu( - title: "Move to…", - image: UIImage(systemName: "arrow.forward.circle"), - identifier: nil, - options: [], - children: - MoveAction.allCases.map { moveAction in - UIAction(title: "First \(moveAction.title)", image: nil, attributes: []) { [weak self] action in - guard let self = self else { return } - self.moveToFirst(action, moveAction: moveAction) - } - } - ) - } - - private func moveToFirst(_ sender: UIAction, moveAction: MoveAction) { - guard let diffableDataSource = viewModel.diffableDataSource else { return } - let snapshot = diffableDataSource.snapshot() - let items = snapshot.itemIdentifiers - guard let targetItem = moveAction.firstMatch(in: items), - let index = snapshot.indexOfItem(targetItem) - else { return } - let indexPath = IndexPath(row: index, section: 0) - tableView.scrollToRow(at: indexPath, at: .middle, animated: true) - tableView.blinkRow(at: indexPath) - } - -} - -extension HomeTimelineViewController { - - @objc private func showFLEXAction(_ sender: UIAction) { - FLEXManager.shared.showExplorer() - } - - @objc private func dropRecentStatusAction(_ sender: UIAction, count: Int) { - guard let diffableDataSource = viewModel.diffableDataSource else { return } - let snapshot = diffableDataSource.snapshot() - - let feedRecords = snapshot.itemIdentifiers.prefix(count).compactMap { item -> ManagedObjectRecord? in - switch item { - case .feed(let record): return record - default: return nil - } - } - let managedObjectContext = viewModel.context.backgroundManagedObjectContext - Task { - try await managedObjectContext.performChanges { - for record in feedRecords { - guard let feed = record.object(in: managedObjectContext) else { continue } - let status = feed.status - managedObjectContext.delete(feed) - if let status = status { - managedObjectContext.delete(status) - } - } // end for in - } // end managedObjectContext.performChanges - } // end Task - } - - @objc private func showWelcomeAction(_ sender: UIAction) { - _ = coordinator.present(scene: .welcome, from: self, transition: .modal(animated: true, completion: nil)) - } - - @objc private func showRegisterAction(_ sender: UIAction) { - Task { @MainActor in - try await showRegisterController() - } // end Task - } - - @MainActor - func showRegisterController(domain: String = "mstdn.jp") async throws { - let viewController = try await MastodonRegisterViewController.create( - context: context, - coordinator: coordinator, - domain: "mstdn.jp" - ) - let navigationController = UINavigationController(rootViewController: viewController) - navigationController.modalPresentationStyle = .fullScreen - present(navigationController, animated: true) { - viewController.navigationItem.leftBarButtonItem = UIBarButtonItem( - systemItem: .close, - primaryAction: UIAction(handler: { [weak viewController] _ in - guard let viewController = viewController else { return } - viewController.dismiss(animated: true) - }), - menu: nil - ) - } - } - - @objc private func showConfirmEmail(_ sender: UIAction) { - let mastodonConfirmEmailViewModel = MastodonConfirmEmailViewModel() - _ = coordinator.present(scene: .mastodonConfirmEmail(viewModel: mastodonConfirmEmailViewModel), from: nil, transition: .modal(animated: true, completion: nil)) - } - - @objc private func showAccountList(_ sender: UIAction) { - let accountListViewModel = AccountListViewModel(context: context, authContext: viewModel.authContext) - _ = coordinator.present(scene: .accountList(viewModel: accountListViewModel), from: self, transition: .modal(animated: true, completion: nil)) - } - - @objc private func showProfileAction(_ sender: UIAction) { - let alertController = UIAlertController(title: "Enter User ID", message: nil, preferredStyle: .alert) - alertController.addTextField() - let showAction = UIAlertAction(title: "Show", style: .default) { [weak self, weak alertController] _ in - guard let self = self else { return } - guard let textField = alertController?.textFields?.first else { return } - let profileViewModel = RemoteProfileViewModel(context: self.context, authContext: self.viewModel.authContext, userID: textField.text ?? "") - _ = self.coordinator.present(scene: .profile(viewModel: profileViewModel), from: self, transition: .show) - } - alertController.addAction(showAction) - let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) - alertController.addAction(cancelAction) - _ = coordinator.present(scene: .alertController(alertController: alertController), from: self, transition: .alertController(animated: true, completion: nil)) - } - - @objc private func showThreadAction(_ sender: UIAction) { - let alertController = UIAlertController(title: "Enter Status ID", message: nil, preferredStyle: .alert) - alertController.addTextField() - let showAction = UIAlertAction(title: "Show", style: .default) { [weak self, weak alertController] _ in - guard let self = self else { return } - guard let textField = alertController?.textFields?.first else { return } - let threadViewModel = RemoteThreadViewModel(context: self.context, authContext: self.viewModel.authContext, statusID: textField.text ?? "") - _ = self.coordinator.present(scene: .thread(viewModel: threadViewModel), from: self, transition: .show) - } - alertController.addAction(showAction) - let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) - alertController.addAction(cancelAction) - _ = coordinator.present(scene: .alertController(alertController: alertController), from: self, transition: .alertController(animated: true, completion: nil)) - } - - private func showNotification(_ sender: UIAction, notificationType: Mastodon.Entity.Notification.NotificationType) { - let alertController = UIAlertController(title: "Enter notification ID", message: nil, preferredStyle: .alert) - alertController.addTextField() - - let showAction = UIAlertAction(title: "Show", style: .default) { [weak self, weak alertController] _ in - guard let self = self else { return } - guard let textField = alertController?.textFields?.first, - let text = textField.text, - let notificationID = Int(text) - else { return } - - let pushNotification = MastodonPushNotification( - accessToken: self.viewModel.authContext.mastodonAuthenticationBox.userAuthorization.accessToken, - notificationID: notificationID, - notificationType: notificationType.rawValue, - preferredLocale: nil, - icon: nil, - title: "", - body: "" - ) - self.context.notificationService.requestRevealNotificationPublisher.send(pushNotification) - } - alertController.addAction(showAction) - - // for multiple accounts debug - let boxes = self.context.authenticationService.mastodonAuthenticationBoxes // already sorted - if boxes.count >= 2 { - let accessToken = boxes[1].userAuthorization.accessToken - let showForSecondaryAction = UIAlertAction(title: "Show for Secondary", style: .default) { [weak self, weak alertController] _ in - guard let self = self else { return } - guard let textField = alertController?.textFields?.first, - let text = textField.text, - let notificationID = Int(text) - else { return } - - let pushNotification = MastodonPushNotification( - accessToken: accessToken, - notificationID: notificationID, - notificationType: notificationType.rawValue, - preferredLocale: nil, - icon: nil, - title: "", - body: "" - ) - self.context.notificationService.requestRevealNotificationPublisher.send(pushNotification) - } - alertController.addAction(showForSecondaryAction) - } - - let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) - alertController.addAction(cancelAction) - - _ = self.coordinator.present( - scene: .alertController(alertController: alertController), - from: self, - transition: .alertController(animated: true, completion: nil) - ) - } - - @objc private func showSettings(_ sender: UIAction) { - guard let currentSetting = context.settingService.currentSetting.value else { return } - let settingsViewModel = SettingsViewModel( - context: context, - authContext: viewModel.authContext, - setting: currentSetting - ) - _ = coordinator.present( - scene: .settings(viewModel: settingsViewModel), - from: self, - transition: .modal(animated: true, completion: nil) - ) - } - -} -#endif diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift index 049683836..c370c992b 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/2/5. // -import os.log import UIKit import AVKit import Combine @@ -21,9 +20,7 @@ import MastodonUI import MastodonLocalization final class HomeTimelineViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - - let logger = Logger(subsystem: "HomeTimelineViewController", category: "UI") - + weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -75,11 +72,6 @@ final class HomeTimelineViewController: UIViewController, NeedsDependency, Media }() let refreshControl = RefreshControl() - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s:", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension HomeTimelineViewController { @@ -100,31 +92,13 @@ extension HomeTimelineViewController { .receive(on: DispatchQueue.main) .sink { [weak self] displaySettingBarButtonItem in guard let self = self else { return } - #if DEBUG - // display debug menu - self.navigationItem.rightBarButtonItem = { - let barButtonItem = UIBarButtonItem() - barButtonItem.image = UIImage(systemName: "ellipsis.circle") - barButtonItem.menu = self.debugMenu - return barButtonItem - }() - #else + self.navigationItem.rightBarButtonItem = displaySettingBarButtonItem ? self.settingBarButtonItem : nil - #endif } .store(in: &disposeBag) - #if DEBUG - // long press to trigger debug menu - settingBarButtonItem.menu = debugMenu - #else + settingBarButtonItem.target = self settingBarButtonItem.action = #selector(HomeTimelineViewController.settingBarButtonItemPressed(_:)) - #endif - - #if SNAPSHOT - titleView.logoButton.menu = self.debugMenu - titleView.button.menu = self.debugMenu - #endif navigationItem.titleView = titleView titleView.delegate = self @@ -274,9 +248,6 @@ extension HomeTimelineViewController { let viewFrameInWindow = self.view.convert(self.view.frame, to: nil) guard xPosition >= viewFrameInWindow.minX && xPosition <= viewFrameInWindow.maxX else { return } - - // works on iOS 14 - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): receive notification \(xPosition)") // check if scroll to top guard self.shouldRestoreScrollPosition() else { return } @@ -478,7 +449,6 @@ extension HomeTimelineViewController { let cellFrameInView = tableView.convert(anchorCell.frame, to: view) return cellFrameInView.origin.y }() - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): save position record for \(anchorIndexPath) with offset: \(offset)") viewModel.scrollPositionRecord = HomeTimelineViewModel.ScrollPositionRecord( item: anchorItem, offset: offset, diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+Diffable.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+Diffable.swift index 6da6a60fa..18cbf18d2 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+Diffable.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+Diffable.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/2/7. // -import os.log import UIKit import CoreData import CoreDataStack diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift index 71dd4ec0e..7f056928c 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/2/5. // -import os.log import func QuartzCore.CACurrentMediaTime import Foundation import CoreData @@ -16,8 +15,6 @@ import MastodonCore extension HomeTimelineViewModel { class LoadLatestState: GKState { - let logger = Logger(subsystem: "HomeTimelineViewModel.LoadLatestState", category: "StateMachine") - let id = UUID() var name: String { @@ -32,8 +29,6 @@ extension HomeTimelineViewModel { override func didEnter(from previousState: GKState?) { super.didEnter(from: previousState) - let previousState = previousState as? HomeTimelineViewModel.LoadLatestState - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] enter \(self.name), previous: \(previousState?.name ?? "")") viewModel?.loadLatestStateMachinePublisher.send(self) } @@ -41,10 +36,6 @@ extension HomeTimelineViewModel { func enter(state: LoadLatestState.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(self.name)") - } } } @@ -98,13 +89,10 @@ extension HomeTimelineViewModel.LoadLatestState { managedObjectContext.parent = parentManagedObjectContext Task { - let start = CACurrentMediaTime() let latestStatusIDs: [Status.ID] = latestFeedRecords.compactMap { record in guard let feed = record.object(in: managedObjectContext) else { return nil } return feed.status?.id } - let end = CACurrentMediaTime() - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: collect statuses id cost: %.2fs", ((#file as NSString).lastPathComponent), #line, #function, end - start) do { let response = try await viewModel.context.apiService.homeTimeline( @@ -119,8 +107,7 @@ extension HomeTimelineViewModel.LoadLatestState { // stop refresher if no new statuses let statuses = response.value let newStatuses = statuses.filter { !latestStatusIDs.contains($0.id) } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): load \(newStatuses.count) new statuses") - + if newStatuses.isEmpty { viewModel.didLoadLatest.send() } else { @@ -136,7 +123,6 @@ extension HomeTimelineViewModel.LoadLatestState { } } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch statuses failed: \(error.localizedDescription)") await enter(state: Idle.self) viewModel.didLoadLatest.send() viewModel.homeTimelineNavigationBarTitleViewModel.receiveLoadingStateCompletion(.failure(error)) diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift index 2b02f0360..1b6e4499d 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift @@ -5,16 +5,13 @@ // Created by sxiaojian on 2021/2/5. // -import os.log import Foundation import GameplayKit import MastodonSDK extension HomeTimelineViewModel { class LoadOldestState: GKState { - - let logger = Logger(subsystem: "HomeTimelineViewModel.LoadOldestState", category: "StateMachine") - + let id = UUID() weak var viewModel: HomeTimelineViewModel? @@ -23,22 +20,10 @@ extension HomeTimelineViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: LoadOldestState.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -97,7 +82,6 @@ extension HomeTimelineViewModel.LoadOldestState { viewModel.homeTimelineNavigationBarTitleViewModel.receiveLoadingStateCompletion(.finished) } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch statues failed: \(error.localizedDescription)") await self.enter(state: Fail.self) viewModel.homeTimelineNavigationBarTitleViewModel.receiveLoadingStateCompletion(.failure(error)) } diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift index 663a38724..040fe45b5 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/2/5. // -import os.log import func AVFoundation.AVMakeRect import UIKit import AVKit @@ -19,8 +18,6 @@ import MastodonUI final class HomeTimelineViewModel: NSObject { - let logger = Logger(subsystem: "HomeTimelineViewModel", category: "ViewModel") - var disposeBag = Set() var observations = Set() @@ -107,11 +104,6 @@ final class HomeTimelineViewModel: NSObject { } .store(in: &disposeBag) } - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s:", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension HomeTimelineViewModel { @@ -176,7 +168,6 @@ extension HomeTimelineViewModel { } catch { assertionFailure(error.localizedDescription) } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch more failure: \(error.localizedDescription)") } // reconfigure item again diff --git a/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift b/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift index 2c201e12b..28475c2d7 100644 --- a/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift +++ b/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/3/15. // -import os.log import UIKit import MastodonUI import MastodonAsset @@ -69,12 +68,10 @@ extension HomeTimelineNavigationBarTitleView { extension HomeTimelineNavigationBarTitleView { @objc private func logoButtonDidPressed(_ sender: UIButton) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.homeTimelineNavigationBarTitleView(self, logoButtonDidPressed: sender) } @objc private func buttonDidPressed(_ sender: UIButton) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.homeTimelineNavigationBarTitleView(self, buttonDidPressed: sender) } } @@ -88,7 +85,6 @@ extension HomeTimelineNavigationBarTitleView { } func configure(state: HomeTimelineNavigationBarTitleViewModel.State) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: configure title view: %s", ((#file as NSString).lastPathComponent), #line, #function, state.rawValue) self.state = state // check state block or not diff --git a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift index defb02fde..10840c35f 100644 --- a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift +++ b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-28. // -import os.log import func AVFoundation.AVMakeRect import UIKit import FLAnimatedImage @@ -92,8 +91,6 @@ extension MediaPreviewImageView { extension MediaPreviewImageView { @objc private func doubleTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - let middleZoomScale = 0.5 * maximumZoomScale if zoomScale >= middleZoomScale { setZoomScale(minimumZoomScale, animated: true) @@ -169,8 +166,6 @@ extension MediaPreviewImageView { } } } - - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: setup image for container %s", ((#file as NSString).lastPathComponent), #line, #function, container.frame.debugDescription) } } @@ -183,7 +178,6 @@ extension MediaPreviewImageView: UIScrollViewDelegate { } func scrollViewDidZoom(_ scrollView: UIScrollView) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) centerScrollViewContents() // set bounce when zoom in diff --git a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift index a431d4dda..2fd2231a1 100644 --- a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift +++ b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-28. // -import os.log import UIKit import Combine import MastodonAsset @@ -32,7 +31,6 @@ final class MediaPreviewImageViewController: UIViewController { let tapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer deinit { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) previewImageView.imageView.af.cancelImageRequest() } } @@ -85,7 +83,6 @@ extension MediaPreviewImageViewController { extension MediaPreviewImageViewController { @objc private func tapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.mediaPreviewImageViewController(self, tapGestureRecognizerDidTrigger: sender) } @@ -131,7 +128,6 @@ extension MediaPreviewImageViewController: UIGestureRecognizerDelegate { // MARK: - UIContextMenuInteractionDelegate extension MediaPreviewImageViewController: UIContextMenuInteractionDelegate { func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) if #available(iOS 16.0, *) { if previewImageView.liveTextInteraction.hasInteractiveItem(at: previewImageView.imageView.convert(location, from: previewImageView)) { @@ -147,7 +143,6 @@ extension MediaPreviewImageViewController: UIContextMenuInteractionDelegate { let saveAction = UIAction( title: L10n.Common.Controls.Actions.savePhoto, image: UIImage(systemName: "square.and.arrow.down")!, identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off ) { [weak self] _ in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: save photo", ((#file as NSString).lastPathComponent), #line, #function) guard let self = self else { return } self.delegate?.mediaPreviewImageViewController(self, contextMenuActionPerform: .savePhoto) } @@ -155,7 +150,6 @@ extension MediaPreviewImageViewController: UIContextMenuInteractionDelegate { let copyAction = UIAction( title: L10n.Common.Controls.Actions.copyPhoto, image: UIImage(systemName: "doc.on.doc")!, identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off ) { [weak self] _ in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: copy photo", ((#file as NSString).lastPathComponent), #line, #function) guard let self = self else { return } self.delegate?.mediaPreviewImageViewController(self, contextMenuActionPerform: .copyPhoto) } @@ -163,7 +157,6 @@ extension MediaPreviewImageViewController: UIContextMenuInteractionDelegate { let shareAction = UIAction( title: L10n.Common.Controls.Actions.share, image: UIImage(systemName: "square.and.arrow.up")!, identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off ) { [weak self] _ in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: share", ((#file as NSString).lastPathComponent), #line, #function) guard let self = self else { return } self.delegate?.mediaPreviewImageViewController(self, contextMenuActionPerform: .share) } diff --git a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewModel.swift b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewModel.swift index 3a4d9edd2..f54f768ee 100644 --- a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewModel.swift +++ b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-28. // -import os.log import UIKit import Combine import Alamofire diff --git a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift index cd94a7f8d..6eaf104e1 100644 --- a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift +++ b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-28. // -import os.log import UIKit import Combine import Pageboy @@ -42,9 +41,6 @@ final class MediaPreviewViewController: UIViewController, NeedsDependency { button.setTitle("ALT", for: .normal) } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -203,7 +199,6 @@ extension MediaPreviewViewController: MediaPreviewingViewController { let safeAreaInsets = previewImageView.safeAreaInsets let statusBarFrameHeight = view.window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0 let dismissible = previewImageView.contentOffset.y <= -(safeAreaInsets.top - statusBarFrameHeight) + 3 // add 3pt tolerance - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: dismissible %s", ((#file as NSString).lastPathComponent), #line, #function, dismissible ? "true" : "false") return dismissible } @@ -211,7 +206,6 @@ extension MediaPreviewViewController: MediaPreviewingViewController { return true } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: dismissible false", ((#file as NSString).lastPathComponent), #line, #function) return false } @@ -309,8 +303,8 @@ extension MediaPreviewViewController: MediaPreviewImageViewControllerDelegate { context.photoLibraryService.copy(imageSource: .url(assetURL)) .sink { completion in switch completion { - case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: copy photo fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) + case .failure(_): + break case .finished: break } diff --git a/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift b/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift index e924f38d4..022e68e2a 100644 --- a/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift +++ b/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift @@ -5,16 +5,13 @@ // Created by MainasuK on 2022-2-9. // -import os.log import UIKit import AVKit import Combine import func AVFoundation.AVMakeRect final class MediaPreviewVideoViewController: UIViewController { - - let logger = Logger(subsystem: "MediaPreviewVideoViewController", category: "ViewController") - + var disposeBag = Set() var viewModel: MediaPreviewVideoViewModel! @@ -23,7 +20,6 @@ final class MediaPreviewVideoViewController: UIViewController { let previewImageView = UIImageView() deinit { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) playerViewController.player?.pause() try? AVAudioSession.sharedInstance().setCategory(.ambient) try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation) @@ -89,24 +85,6 @@ extension MediaPreviewVideoViewController { } // MARK: - ShareActivityProvider -//extension MediaPreviewVideoViewController: ShareActivityProvider { -// var activities: [Any] { -// return [] -// } -// -// var applicationActivities: [UIActivity] { -// switch viewModel.item { -// case .gif(let mediaContext): -// guard let url = mediaContext.assetURL else { return [] } -// return [ -// SavePhotoActivity(context: viewModel.context, url: url, resourceType: .video) -// ] -// default: -// return [] -// } -// } -//} - extension MediaPreviewVideoViewController: MediaPreviewPage { func setShowingChrome(_ showingChrome: Bool) { // TODO: does this do anything? diff --git a/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewModel.swift b/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewModel.swift index a6542d464..04fd86011 100644 --- a/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewModel.swift +++ b/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-2-9. // -import os.log import UIKit import AVKit import Combine @@ -14,8 +13,6 @@ import MastodonCore final class MediaPreviewVideoViewModel { - let logger = Logger(subsystem: "MediaPreviewVideoViewModel", category: "ViewModel") - var disposeBag = Set() // input @@ -59,10 +56,7 @@ final class MediaPreviewVideoViewModel { // setup player state observer $playbackState .receive(on: DispatchQueue.main) - .sink { [weak self] status in - guard let self = self else { return } - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): player state: \(status.description)") - + .sink { status in switch status { case .unknown, .buffering, .readyToPlay: break diff --git a/Mastodon/Scene/Notification/Cell/NotificationTableViewCell+ViewModel.swift b/Mastodon/Scene/Notification/Cell/NotificationTableViewCell+ViewModel.swift index 7b994076a..1d2b40ebc 100644 --- a/Mastodon/Scene/Notification/Cell/NotificationTableViewCell+ViewModel.swift +++ b/Mastodon/Scene/Notification/Cell/NotificationTableViewCell+ViewModel.swift @@ -33,8 +33,7 @@ extension NotificationTableViewCell { if notificationView.frame == .zero { // set status view width notificationView.frame.size.width = tableView.frame.width - containerViewHorizontalMargin - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): did layout for new cell") - + notificationView.statusView.frame.size.width = tableView.frame.width - containerViewHorizontalMargin notificationView.quoteStatusView.frame.size.width = tableView.frame.width - containerViewHorizontalMargin // the as same width as statusView } @@ -52,10 +51,8 @@ extension NotificationTableViewCell { ) .dropFirst() .receive(on: DispatchQueue.main) - .sink { [weak tableView, weak self] _, _ in + .sink { [weak tableView] _, _ in guard let tableView = tableView else { return } - guard let self = self else { return } - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): tableView updates") UIView.performWithoutAnimation { tableView.beginUpdates() diff --git a/Mastodon/Scene/Notification/Cell/NotificationTableViewCell.swift b/Mastodon/Scene/Notification/Cell/NotificationTableViewCell.swift index d8949e391..bce1ccf7a 100644 --- a/Mastodon/Scene/Notification/Cell/NotificationTableViewCell.swift +++ b/Mastodon/Scene/Notification/Cell/NotificationTableViewCell.swift @@ -5,16 +5,12 @@ // Created by MainasuK on 2022-1-21. // -import os.log import UIKit import Combine import MastodonCore import MastodonUI final class NotificationTableViewCell: UITableViewCell { - - let logger = Logger(subsystem: "NotificationTableViewCell", category: "View") - weak var delegate: NotificationTableViewCellDelegate? var disposeBag = Set() private var _disposeBag = Set() diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift index 9b7416afc..d081327d3 100644 --- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift +++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-21. // -import os.log import UIKit import Combine import CoreDataStack @@ -14,8 +13,6 @@ import MastodonLocalization final class NotificationTimelineViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - let logger = Logger(subsystem: "NotificationTimelineViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -42,9 +39,6 @@ final class NotificationTimelineViewController: UIViewController, NeedsDependenc let cellFrameCache = NSCache() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -101,13 +95,10 @@ extension NotificationTimelineViewController { let now = Date() if let timestamp = viewModel.lastAutomaticFetchTimestamp { if now.timeIntervalSince(timestamp) > 60 { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): auto fetch latest timeline…") Task { await viewModel.loadLatest() } viewModel.lastAutomaticFetchTimestamp = now - } else { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): auto fetch latest timeline skip. Reason: updated in recent 60s") } } else { Task { @@ -133,8 +124,6 @@ extension NotificationTimelineViewController: CellFrameCacheContainer { extension NotificationTimelineViewController { @objc private func refreshControlValueChanged(_ sender: RefreshControl) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - Task { await viewModel.loadLatest() } diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+Diffable.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+Diffable.swift index 0331f401e..c412c39a4 100644 --- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+Diffable.swift +++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+Diffable.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-21. // -import os.log import UIKit import CoreData import CoreDataStack @@ -36,14 +35,8 @@ extension NotificationTimelineViewModel { .sink { [weak self] records in guard let self = self else { return } guard let diffableDataSource = self.diffableDataSource else { return } - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): incoming \(records.count) objects") Task { - let start = CACurrentMediaTime() - defer { - let end = CACurrentMediaTime() - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): cost \(end - start, format: .fixed(precision: 4))s to process \(records.count) feeds") - } let oldSnapshot = diffableDataSource.snapshot() var newSnapshot: NSDiffableDataSourceSnapshot = { let newItems = records.map { record in @@ -88,16 +81,12 @@ extension NotificationTimelineViewModel { let hasChanges = newSnapshot.itemIdentifiers != oldSnapshot.itemIdentifiers if !hasChanges { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): snapshot not changes") self.didLoadLatest.send() return - } else { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): snapshot has changes") } await self.updateSnapshotUsingReloadData(snapshot: newSnapshot) self.didLoadLatest.send() - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): applied new snapshot") } // end Task } .store(in: &disposeBag) diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+LoadOldestState.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+LoadOldestState.swift index ff23d8d6e..3be724701 100644 --- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+LoadOldestState.swift +++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+LoadOldestState.swift @@ -9,13 +9,10 @@ import CoreDataStack import Foundation import GameplayKit import MastodonSDK -import os.log extension NotificationTimelineViewModel { class LoadOldestState: GKState { - let logger = Logger(subsystem: "NotificationTimelineViewModel.LoadOldestState", category: "StateMachine") - let id = UUID() weak var viewModel: NotificationTimelineViewModel? @@ -24,22 +21,10 @@ extension NotificationTimelineViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: LoadOldestState.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -98,7 +83,6 @@ extension NotificationTimelineViewModel.LoadOldestState { } } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch statues failed: \(error.localizedDescription)") await self.enter(state: Fail.self) } } // end Task diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift index f4ce7c2d7..a6412d365 100644 --- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift +++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-21. // -import os.log import UIKit import Combine import CoreDataStack @@ -15,8 +14,6 @@ import MastodonCore final class NotificationTimelineViewModel { - let logger = Logger(subsystem: "NotificationTimelineViewModel", category: "ViewModel") - var disposeBag = Set() // input @@ -63,9 +60,6 @@ final class NotificationTimelineViewModel { ) } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -125,7 +119,6 @@ extension NotificationTimelineViewModel { ) } catch { didLoadLatest.send() - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(error.localizedDescription)") } } @@ -155,7 +148,6 @@ extension NotificationTimelineViewModel { authenticationBox: authContext.mastodonAuthenticationBox ) } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch more failure: \(error.localizedDescription)") } } diff --git a/Mastodon/Scene/Notification/NotificationViewController.swift b/Mastodon/Scene/Notification/NotificationViewController.swift index 79232c072..502e04b7c 100644 --- a/Mastodon/Scene/Notification/NotificationViewController.swift +++ b/Mastodon/Scene/Notification/NotificationViewController.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/4/12. // -import os.log import UIKit import Combine import MastodonAsset @@ -16,8 +15,6 @@ import MastodonCore final class NotificationViewController: TabmanViewController, NeedsDependency { - let logger = Logger(subsystem: "NotificationViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -44,9 +41,6 @@ final class NotificationViewController: TabmanViewController, NeedsDependency { viewModel.currentPageIndex = index } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } extension NotificationViewController { @@ -163,8 +157,6 @@ extension NotificationViewController { extension NotificationViewController { @objc private func pageSegmentedControlValueChanged(_ sender: UISegmentedControl) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - let index = sender.selectedSegmentIndex scrollToPage(.at(index: index), animated: true, completion: nil) } @@ -232,7 +224,6 @@ extension NotificationViewController { } @objc private func showCategory(_ sender: UIKeyCommand) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) guard let rawValue = sender.propertyList as? String, let category = CategorySwitch(rawValue: rawValue) else { return } diff --git a/Mastodon/Scene/Notification/NotificationViewModel.swift b/Mastodon/Scene/Notification/NotificationViewModel.swift index 039653ee5..39c1b9ca5 100644 --- a/Mastodon/Scene/Notification/NotificationViewModel.swift +++ b/Mastodon/Scene/Notification/NotificationViewModel.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/4/12. // -import os.log import UIKit import Combine import Pageboy diff --git a/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift b/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift index e2eddc16c..62a861f8c 100644 --- a/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift +++ b/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift @@ -7,7 +7,6 @@ import Combine import MastodonSDK -import os.log import UIKit import MastodonAsset import MastodonCore @@ -104,8 +103,8 @@ extension MastodonConfirmEmailViewController { .receive(on: DispatchQueue.main) .sink { completion in switch completion { - case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: swap user access token swap fail: %s", (#file as NSString).lastPathComponent, #line, #function, error.localizedDescription) + case .failure(_): + break case .finished: // upload avatar and set display name in the background Just(self.viewModel.userToken.accessToken) @@ -119,10 +118,10 @@ extension MastodonConfirmEmailViewController { .retry(3) .sink { completion in switch completion { - case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: setup avatar & display name fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) - case .finished: - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: setup avatar & display name success", ((#file as NSString).lastPathComponent), #line, #function) + case .failure(_): + break + case .finished: + break } } receiveValue: { _ in // do nothing @@ -130,7 +129,6 @@ extension MastodonConfirmEmailViewController { .store(in: &self.context.disposeBag) // execute in the background } // end switch } receiveValue: { response in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: user %s's email confirmed", ((#file as NSString).lastPathComponent), #line, #function, response.value.username) self.coordinator.setup() // self.dismiss(animated: true, completion: nil) } diff --git a/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift b/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift index 7a02b903c..1ca300c8f 100644 --- a/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift +++ b/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift @@ -228,15 +228,10 @@ class MastodonLoginViewController: UIViewController, NeedsDependency { @objc func keyboardWillShowNotification(_ notification: Notification) { guard let userInfo = notification.userInfo, - let keyboardFrameValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue, let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber else { return } // inspired by https://stackoverflow.com/a/30245044 - let keyboardFrame = keyboardFrameValue.cgRectValue - - let keyboardOrigin = view.convert(keyboardFrame.origin, from: nil) - UIView.animate(withDuration: duration.doubleValue, delay: 0, options: .curveEaseInOut) { self.view.layoutIfNeeded() } diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift index 5618f2790..886b138b1 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift @@ -5,7 +5,6 @@ // Created by BradGao on 2021/2/20. // -import os.log import UIKit import Combine import GameController diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel+LoadIndexedServerState.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel+LoadIndexedServerState.swift index 0c4910d17..f7ccebd84 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel+LoadIndexedServerState.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel+LoadIndexedServerState.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021/3/5. // -import os.log import Foundation import GameplayKit import MastodonSDK @@ -17,10 +16,6 @@ extension MastodonPickServerViewModel { init(viewModel: MastodonPickServerViewModel) { self.viewModel = viewModel } - - override func didEnter(from previousState: GKState?) { - os_log("%{public}s[%{public}ld], %{public}s: enter %s, previous: %s", ((#file as NSString).lastPathComponent), #line, #function, self.debugDescription, previousState.debugDescription) - } } } diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift index 19e9bab3c..00a287b22 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift @@ -5,7 +5,6 @@ // Created by BradGao on 2021/2/23. // -import os.log import UIKit import Combine import GameplayKit @@ -79,9 +78,6 @@ class MastodonPickServerViewModel: NSObject { configure() } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift index 694418c32..9d9f43f59 100644 --- a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift +++ b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift @@ -5,7 +5,6 @@ // Created by BradGao on 2021/2/24. // -import os.log import UIKit import Combine import MastodonSDK diff --git a/Mastodon/Scene/Onboarding/PickServer/View/PickServerServerSectionTableHeaderView.swift b/Mastodon/Scene/Onboarding/PickServer/View/PickServerServerSectionTableHeaderView.swift index 7c686cfb2..a29a4ca74 100644 --- a/Mastodon/Scene/Onboarding/PickServer/View/PickServerServerSectionTableHeaderView.swift +++ b/Mastodon/Scene/Onboarding/PickServer/View/PickServerServerSectionTableHeaderView.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-4. // -import os.log import UIKit import Tabman import MastodonAsset diff --git a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift index 588e3a175..c327357bc 100644 --- a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift +++ b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift @@ -8,7 +8,6 @@ import AlamofireImage import Combine import MastodonSDK -import os.log import PhotosUI import UIKit import SwiftUI @@ -21,8 +20,6 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O static let avatarImageMaxSizeInPixel = CGSize(width: 400, height: 400) - let logger = Logger(subsystem: "MastodonRegisterViewController", category: "ViewController") - var disposeBag = Set() private var observations = Set() diff --git a/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewController.swift b/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewController.swift index d6870785c..da43547f2 100644 --- a/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewController.swift +++ b/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewController.swift @@ -6,7 +6,6 @@ // import Combine -import os.log import UIKit import WebKit import MastodonCore @@ -27,8 +26,6 @@ final class MastodonResendEmailViewController: UIViewController, NeedsDependency }() deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", (#file as NSString).lastPathComponent, #line, #function) - // cleanup cookie let httpCookieStore = webView.configuration.websiteDataStore.httpCookieStore httpCookieStore.getAllCookies { cookies in @@ -54,7 +51,6 @@ extension MastodonResendEmailViewController { let request = URLRequest(url: viewModel.resendEmailURL) webView.navigationDelegate = self.viewModel.navigationDelegate webView.load(request) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: resendEmail via: %s", (#file as NSString).lastPathComponent, #line, #function, viewModel.resendEmailURL.debugDescription) } } diff --git a/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewModel.swift b/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewModel.swift index dc907cc6c..c552c0b8a 100644 --- a/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewModel.swift +++ b/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewModel.swift @@ -7,7 +7,6 @@ import Combine import Foundation -import os.log import WebKit final class MastodonResendEmailViewModel { @@ -22,11 +21,6 @@ final class MastodonResendEmailViewModel { self.resendEmailURL = resendEmailURL self.email = email } - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", (#file as NSString).lastPathComponent, #line, #function) - } - } extension MastodonResendEmailViewModel { diff --git a/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewModelNavigationDelegateShim.swift b/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewModelNavigationDelegateShim.swift index 4a27de96d..79ea5550d 100644 --- a/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewModelNavigationDelegateShim.swift +++ b/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewModelNavigationDelegateShim.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/2/25. // -import os.log import Foundation import WebKit @@ -17,9 +16,6 @@ final class MastodonResendEmailViewModelNavigationDelegateShim: NSObject { self.viewModel = viewModel } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift index 871f115ff..49b85106c 100644 --- a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift +++ b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-2-22. // -import os.log import UIKit import Combine import MastodonSDK @@ -16,9 +15,6 @@ import MastodonCore import MastodonLocalization final class MastodonServerRulesViewController: UIViewController, NeedsDependency { - - let logger = Logger(subsystem: "MastodonServerRulesViewController", category: "ViewController") - var disposeBag = Set() private var observations = Set() diff --git a/Mastodon/Scene/Onboarding/Share/AuthenticationViewModel.swift b/Mastodon/Scene/Onboarding/Share/AuthenticationViewModel.swift index 868b14641..192eefb65 100644 --- a/Mastodon/Scene/Onboarding/Share/AuthenticationViewModel.swift +++ b/Mastodon/Scene/Onboarding/Share/AuthenticationViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021/2/1. // -import os.log import UIKit import CoreData import CoreDataStack @@ -75,9 +74,7 @@ extension AuthenticationViewModel { let components = host.components(separatedBy: ".") guard !components.contains(where: { $0.isEmpty }) else { return nil } guard components.count >= 2 else { return nil } - - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: input host: %s", ((#file as NSString).lastPathComponent), #line, #function, host) - + return host } } @@ -156,7 +153,6 @@ extension AuthenticationViewModel { ) .flatMap { response -> AnyPublisher, Error> in let token = response.value - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: sign in success. Token: %s", ((#file as NSString).lastPathComponent), #line, #function, token.accessToken) return AuthenticationViewModel.verifyAndSaveAuthentication( context: self.context, info: info, @@ -171,7 +167,6 @@ extension AuthenticationViewModel { guard let self = self else { return } switch completion { case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: swap user access token swap fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) self.isAuthenticating.value = false self.error.value = error case .finished: @@ -180,7 +175,6 @@ extension AuthenticationViewModel { } receiveValue: { [weak self] response in guard let self = self else { return } let account = response.value - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: user %s sign in success", ((#file as NSString).lastPathComponent), #line, #function, account.username) self.authenticated.send((domain: info.domain, account: account)) } diff --git a/Mastodon/Scene/Onboarding/Share/MastodonAuthenticationController.swift b/Mastodon/Scene/Onboarding/Share/MastodonAuthenticationController.swift index e56c7f126..32e76ea5d 100644 --- a/Mastodon/Scene/Onboarding/Share/MastodonAuthenticationController.swift +++ b/Mastodon/Scene/Onboarding/Share/MastodonAuthenticationController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-6-4. // -import os.log import UIKit import Combine import AuthenticationServices @@ -44,12 +43,10 @@ extension MastodonAuthenticationController { callbackURLScheme: APIService.callbackURLScheme ) { [weak self] callback, error in guard let self = self else { return } - os_log("%{public}s[%{public}ld], %{public}s: callback: %s, error: %s", ((#file as NSString).lastPathComponent), #line, #function, callback?.debugDescription ?? "", error.debugDescription) - + if let error = error { if let error = error as? ASWebAuthenticationSessionError { if error.errorCode == ASWebAuthenticationSessionError.canceledLogin.rawValue { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: user cancel authentication", ((#file as NSString).lastPathComponent), #line, #function) self.isAuthenticating.value = false return } diff --git a/Mastodon/Scene/Profile/About/Cell/ProfileFieldAddEntryCollectionViewCell.swift b/Mastodon/Scene/Profile/About/Cell/ProfileFieldAddEntryCollectionViewCell.swift index f630ec696..e71e3fad7 100644 --- a/Mastodon/Scene/Profile/About/Cell/ProfileFieldAddEntryCollectionViewCell.swift +++ b/Mastodon/Scene/Profile/About/Cell/ProfileFieldAddEntryCollectionViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-5-26. // -import os.log import UIKit import Combine import MastodonAsset diff --git a/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift b/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift index 00fd21b22..df0719ff1 100644 --- a/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift +++ b/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-5-25. // -import os.log import UIKit import Combine import MetaTextKit @@ -186,7 +185,6 @@ extension ProfileFieldCollectionViewCell { // MARK: - MetaLabelDelegate extension ProfileFieldCollectionViewCell: MetaLabelDelegate { func metaLabel(_ metaLabel: MetaLabel, didSelectMeta meta: Meta) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.profileFieldCollectionViewCell(self, metaLabel: metaLabel, didSelectMeta: meta) } } diff --git a/Mastodon/Scene/Profile/About/Cell/ProfileFieldEditCollectionViewCell.swift b/Mastodon/Scene/Profile/About/Cell/ProfileFieldEditCollectionViewCell.swift index c7005867c..7cc00ec5c 100644 --- a/Mastodon/Scene/Profile/About/Cell/ProfileFieldEditCollectionViewCell.swift +++ b/Mastodon/Scene/Profile/About/Cell/ProfileFieldEditCollectionViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-22. // -import os.log import UIKit import Combine import MetaTextKit @@ -127,7 +126,6 @@ extension ProfileFieldEditCollectionViewCell { extension ProfileFieldEditCollectionViewCell { @objc private func editButtonDidPressed(_ sender: UIButton) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.profileFieldEditCollectionViewCell(self, editButtonDidPressed: sender) } } diff --git a/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift b/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift index 2a96a86ab..1a1a1ac6c 100644 --- a/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift +++ b/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-22. // -import os.log import UIKit import Combine import MetaTextKit @@ -20,8 +19,6 @@ protocol ProfileAboutViewControllerDelegate: AnyObject { final class ProfileAboutViewController: UIViewController { - let logger = Logger(subsystem: "ProfileAboutViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -39,9 +36,6 @@ final class ProfileAboutViewController: UIViewController { return collectionView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -129,7 +123,6 @@ extension ProfileAboutViewController { // MARK: - UICollectionViewDelegate extension ProfileAboutViewController: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): select \(indexPath.debugDescription)") guard let diffableDataSource = viewModel.diffableDataSource else { return } guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return } diff --git a/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift b/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift index eb7a6aaae..5f37f90c1 100644 --- a/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift +++ b/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-22. // -import os.log import UIKit import Combine import MastodonSDK diff --git a/Mastodon/Scene/Profile/About/ProfileAboutViewModel.swift b/Mastodon/Scene/Profile/About/ProfileAboutViewModel.swift index 8ab427c39..f9a0b1c9d 100644 --- a/Mastodon/Scene/Profile/About/ProfileAboutViewModel.swift +++ b/Mastodon/Scene/Profile/About/ProfileAboutViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-22. // -import os.log import UIKit import Combine import CoreDataStack diff --git a/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift b/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift index 458c47335..e4666ad28 100644 --- a/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift +++ b/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift @@ -5,7 +5,6 @@ // Created by ProtoLimit on 2022-07-19. // -import os.log import UIKit import AVKit import Combine @@ -17,8 +16,6 @@ import MastodonLocalization final class BookmarkViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - let logger = Logger(subsystem: "BookmarkViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -39,9 +36,6 @@ final class BookmarkViewController: UIViewController, NeedsDependency, MediaPrev return tableView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+State.swift b/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+State.swift index e86ee92cc..f746a5acb 100644 --- a/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+State.swift +++ b/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+State.swift @@ -5,7 +5,6 @@ // Created by ProtoLimit on 2022-07-19. // -import os.log import Foundation import GameplayKit import MastodonSDK @@ -14,8 +13,6 @@ import MastodonCore extension BookmarkViewModel { class State: GKState { - let logger = Logger(subsystem: "BookmarkViewModel.State", category: "StateMachine") - let id = UUID() weak var viewModel: BookmarkViewModel? @@ -24,22 +21,11 @@ extension BookmarkViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -91,9 +77,7 @@ extension BookmarkViewModel.State { super.didEnter(from: previousState) guard let _ = viewModel, let stateMachine = stateMachine else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading 3s later…", ((#file as NSString).lastPathComponent), #line, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading", ((#file as NSString).lastPathComponent), #line, #function) stateMachine.enter(Loading.self) } } @@ -165,7 +149,6 @@ extension BookmarkViewModel.State { } viewModel.statusFetchedResultsController.statusIDs = statusIDs } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch user bookmarks fail: \(error.localizedDescription)") await enter(state: Fail.self) } } // end Task diff --git a/Mastodon/Scene/Profile/CachedProfileViewModel.swift b/Mastodon/Scene/Profile/CachedProfileViewModel.swift index cdd572fc4..a769f2a9f 100644 --- a/Mastodon/Scene/Profile/CachedProfileViewModel.swift +++ b/Mastodon/Scene/Profile/CachedProfileViewModel.swift @@ -13,8 +13,5 @@ final class CachedProfileViewModel: ProfileViewModel { init(context: AppContext, authContext: AuthContext, mastodonUser: MastodonUser) { super.init(context: context, authContext: authContext, optionalMastodonUser: mastodonUser) - - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Profile] user[\(mastodonUser.id)] profile: \(mastodonUser.acctWithDomain)") } - } diff --git a/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift b/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift index 56bebaad7..c181f4e95 100644 --- a/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift +++ b/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-17. // -import os.log import UIKit import Combine import MastodonCore @@ -15,8 +14,6 @@ import CoreDataStack final class FamiliarFollowersViewController: UIViewController, NeedsDependency { - let logger = Logger(subsystem: "FamiliarFollowersViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -31,9 +28,6 @@ final class FamiliarFollowersViewController: UIViewController, NeedsDependency { return tableView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift b/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift index 19f25f3ad..9c55f988f 100644 --- a/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift +++ b/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift @@ -8,7 +8,6 @@ // Note: Prefer use US favorite then EN favourite in coding // to following the text checker auto-correct behavior -import os.log import UIKit import AVKit import Combine @@ -20,8 +19,6 @@ import MastodonLocalization final class FavoriteViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - let logger = Logger(subsystem: "FavoriteViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -42,9 +39,6 @@ final class FavoriteViewController: UIViewController, NeedsDependency, MediaPrev return tableView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+State.swift b/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+State.swift index c2dc27201..a1a8d0f99 100644 --- a/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+State.swift +++ b/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+State.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-7. // -import os.log import Foundation import GameplayKit import MastodonCore @@ -14,8 +13,6 @@ import MastodonSDK extension FavoriteViewModel { class State: GKState { - let logger = Logger(subsystem: "FavoriteViewModel.State", category: "StateMachine") - let id = UUID() weak var viewModel: FavoriteViewModel? @@ -23,23 +20,11 @@ extension FavoriteViewModel { init(viewModel: FavoriteViewModel) { self.viewModel = viewModel } - - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - + @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -91,9 +76,7 @@ extension FavoriteViewModel.State { super.didEnter(from: previousState) guard let _ = viewModel, let stateMachine = stateMachine else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading 3s later…", ((#file as NSString).lastPathComponent), #line, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading", ((#file as NSString).lastPathComponent), #line, #function) stateMachine.enter(Loading.self) } } @@ -165,7 +148,6 @@ extension FavoriteViewModel.State { } viewModel.statusFetchedResultsController.statusIDs = statusIDs } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch user favorites fail: \(error.localizedDescription)") await enter(state: Fail.self) } } // end Task diff --git a/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewController.swift b/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewController.swift index 9a31fe0c3..7839832bf 100644 --- a/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewController.swift +++ b/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewController.swift @@ -14,8 +14,6 @@ import MastodonUI import MastodonLocalization final class FollowedTagsViewController: UIViewController, NeedsDependency { - let logger = Logger(subsystem: String(describing: FollowedTagsViewController.self), category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -33,9 +31,6 @@ final class FollowedTagsViewController: UIViewController, NeedsDependency { return tableView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } extension FollowedTagsViewController { diff --git a/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewModel.swift b/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewModel.swift index 91e6c36ca..f73094a8c 100644 --- a/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewModel.swift +++ b/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewModel.swift @@ -14,7 +14,6 @@ import MastodonSDK import MastodonCore final class FollowedTagsViewModel: NSObject { - let logger = Logger(subsystem: String(describing: FollowedTagsViewModel.self), category: "ViewModel") var disposeBag = Set() let fetchedResultsController: FollowedTagsFetchedResultController @@ -93,7 +92,6 @@ extension FollowedTagsViewModel { extension FollowedTagsViewModel: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(indexPath)") tableView.deselectRow(at: indexPath, animated: true) let object = fetchedResultsController.records[indexPath.row] diff --git a/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift b/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift index 8094a77d7..501267813 100644 --- a/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift +++ b/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-11-1. // -import os.log import UIKit import GameplayKit import Combine @@ -16,8 +15,6 @@ import CoreDataStack final class FollowerListViewController: UIViewController, NeedsDependency { - let logger = Logger(subsystem: "FollowerListViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -35,9 +32,6 @@ final class FollowerListViewController: UIViewController, NeedsDependency { return tableView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift b/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift index 531c2c380..fb7b20166 100644 --- a/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift +++ b/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-11-1. // -import os.log import Foundation import GameplayKit import MastodonSDK @@ -15,8 +14,6 @@ import CoreDataStack extension FollowerListViewModel { class State: GKState { - let logger = Logger(subsystem: "FollowerListViewModel.State", category: "StateMachine") - let id = UUID() var name: String { @@ -29,22 +26,10 @@ extension FollowerListViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -97,9 +82,7 @@ extension FollowerListViewModel.State { super.didEnter(from: previousState) guard let _ = viewModel, let stateMachine = stateMachine else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading 3s later…", ((#file as NSString).lastPathComponent), #line, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading", ((#file as NSString).lastPathComponent), #line, #function) stateMachine.enter(Loading.self) } } @@ -154,7 +137,6 @@ extension FollowerListViewModel.State { maxID: maxID, authenticationBox: viewModel.authContext.mastodonAuthenticationBox ) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch \(response.value.count) followers") var hasNewAppend = false var userIDs = viewModel.userFetchedResultsController.userIDs @@ -176,7 +158,6 @@ extension FollowerListViewModel.State { viewModel.userFetchedResultsController.userIDs = userIDs } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch follower fail: \(error.localizedDescription)") await enter(state: Fail.self) } } // end Task diff --git a/Mastodon/Scene/Profile/Following/FollowingListViewController.swift b/Mastodon/Scene/Profile/Following/FollowingListViewController.swift index 336eb333e..c80b3169b 100644 --- a/Mastodon/Scene/Profile/Following/FollowingListViewController.swift +++ b/Mastodon/Scene/Profile/Following/FollowingListViewController.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-11-2. // -import os.log import UIKit import GameplayKit import Combine @@ -15,8 +14,6 @@ import MastodonUI import CoreDataStack final class FollowingListViewController: UIViewController, NeedsDependency { - - let logger = Logger(subsystem: "FollowingListViewController", category: "ViewController") weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -35,9 +32,6 @@ final class FollowingListViewController: UIViewController, NeedsDependency { return tableView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift b/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift index 723e66c8e..df71c0d7c 100644 --- a/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift +++ b/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift @@ -5,15 +5,12 @@ // Created by Cirno MainasuK on 2021-11-2. // -import os.log import Foundation import GameplayKit import MastodonSDK extension FollowingListViewModel { class State: GKState { - - let logger = Logger(subsystem: "FollowingListViewModel.State", category: "StateMachine") let id = UUID() @@ -23,22 +20,10 @@ extension FollowingListViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -91,9 +76,7 @@ extension FollowingListViewModel.State { super.didEnter(from: previousState) guard let _ = viewModel, let stateMachine = stateMachine else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading 3s later…", ((#file as NSString).lastPathComponent), #line, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading", ((#file as NSString).lastPathComponent), #line, #function) stateMachine.enter(Loading.self) } } @@ -148,9 +131,7 @@ extension FollowingListViewModel.State { maxID: maxID, authenticationBox: viewModel.authContext.mastodonAuthenticationBox ) - - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch \(response.value.count)") - + var hasNewAppend = false var userIDs = viewModel.userFetchedResultsController.userIDs for user in response.value { @@ -170,7 +151,6 @@ extension FollowingListViewModel.State { viewModel.userFetchedResultsController.userIDs = userIDs } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch following fail: \(error.localizedDescription)") await enter(state: Fail.self) } } // end Task diff --git a/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift b/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift index 934d7d4c4..d912173be 100644 --- a/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift +++ b/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-29. // -import os.log import UIKit import Combine import CoreDataStack @@ -27,8 +26,6 @@ protocol ProfileHeaderViewControllerDelegate: AnyObject { final class ProfileHeaderViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - let logger = Logger(subsystem: "ProfileHeaderViewController", category: "ViewController") - static let segmentedControlHeight: CGFloat = 50 static let headerMinHeight: CGFloat = segmentedControlHeight @@ -84,9 +81,6 @@ final class ProfileHeaderViewController: UIViewController, NeedsDependency, Medi return documentPickerController }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -202,7 +196,6 @@ extension ProfileHeaderViewController { var children: [UIMenuElement] = [] let photoLibraryAction = UIAction(title: L10n.Scene.Compose.MediaSelection.photoLibrary, image: UIImage(systemName: "rectangle.on.rectangle"), identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off) { [weak self] _ in guard let self = self else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: mediaSelectionType: .photoLibaray", ((#file as NSString).lastPathComponent), #line, #function) self.currentImageType = type self.present(self.imagePicker, animated: true, completion: nil) } @@ -210,7 +203,6 @@ extension ProfileHeaderViewController { if UIImagePickerController.isSourceTypeAvailable(.camera) { let cameraAction = UIAction(title: L10n.Scene.Compose.MediaSelection.camera, image: UIImage(systemName: "camera"), identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off, handler: { [weak self] _ in guard let self = self else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: mediaSelectionType: .camera", ((#file as NSString).lastPathComponent), #line, #function) self.currentImageType = type self.present(self.imagePickerController, animated: true, completion: nil) }) @@ -218,7 +210,6 @@ extension ProfileHeaderViewController { } let browseAction = UIAction(title: L10n.Scene.Compose.MediaSelection.browse, image: UIImage(systemName: "ellipsis"), identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off) { [weak self] _ in guard let self = self else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: mediaSelectionType: .browse", ((#file as NSString).lastPathComponent), #line, #function) self.currentImageType = type self.present(self.documentPickerController, animated: true, completion: nil) } @@ -384,8 +375,6 @@ extension ProfileHeaderViewController: ProfileHeaderViewDelegate { // MARK: - MetaTextDelegate extension ProfileHeaderViewController: MetaTextDelegate { func metaText(_ metaText: MetaText, processEditing textStorage: MetaTextStorage) -> MetaContent? { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: text: %s", ((#file as NSString).lastPathComponent), #line, #function, metaText.backedString) - switch metaText { case profileHeaderView.bioMetaText: guard viewModel.isEditing else { break } @@ -438,7 +427,6 @@ extension ProfileHeaderViewController: UIImagePickerControllerDelegate & UINavig } func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) picker.dismiss(animated: true, completion: nil) } } @@ -455,7 +443,6 @@ extension ProfileHeaderViewController: UIDocumentPickerDelegate { guard let image = UIImage(data: imageData) else { return } cropImage(image: image, pickerViewController: controller) } catch { - os_log("%{public}s[%{public}ld], %{public}s: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) } } } diff --git a/Mastodon/Scene/Profile/Header/ProfileHeaderViewModel.swift b/Mastodon/Scene/Profile/Header/ProfileHeaderViewModel.swift index 3025907e0..9301aea50 100644 --- a/Mastodon/Scene/Profile/Header/ProfileHeaderViewModel.swift +++ b/Mastodon/Scene/Profile/Header/ProfileHeaderViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-9. // -import os.log import UIKit import Combine import CoreDataStack diff --git a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView+Configuration.swift b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView+Configuration.swift index ac33227cc..8e1693142 100644 --- a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView+Configuration.swift +++ b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView+Configuration.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-26. // -import os.log import UIKit import Combine import CoreDataStack diff --git a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView+ViewModel.swift b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView+ViewModel.swift index 961a8269a..270f86b64 100644 --- a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView+ViewModel.swift +++ b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView+ViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-26. // -import os.log import UIKit import Combine import CoreDataStack diff --git a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift index e5032b5bd..7a906c05c 100644 --- a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift +++ b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-29. // -import os.log import UIKit import Combine import FLAnimatedImage @@ -511,19 +510,16 @@ extension ProfileHeaderView { extension ProfileHeaderView { @objc private func relationshipActionButtonDidPressed(_ sender: UIButton) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) assert(sender === relationshipActionButton) delegate?.profileHeaderView(self, relationshipButtonDidPressed: relationshipActionButton) } @objc private func avatarButtonDidPressed(_ sender: UIButton) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) assert(sender === avatarButton) delegate?.profileHeaderView(self, avatarButtonDidPressed: avatarButton) } @objc private func bannerImageViewDidPressed(_ sender: UITapGestureRecognizer) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.profileHeaderView(self, bannerImageViewDidPressed: bannerImageView) } } @@ -544,7 +540,6 @@ extension ProfileHeaderView: UITextViewDelegate { // MARK: - MetaTextViewDelegate extension ProfileHeaderView: MetaTextViewDelegate { func metaTextView(_ metaTextView: MetaTextView, didSelectMeta meta: Meta) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: select entity", ((#file as NSString).lastPathComponent), #line, #function) delegate?.profileHeaderView(self, metaTextView: metaTextView, metaDidPressed: meta) } } diff --git a/Mastodon/Scene/Profile/MeProfileViewModel.swift b/Mastodon/Scene/Profile/MeProfileViewModel.swift index 35da62eb7..7f88d2ffe 100644 --- a/Mastodon/Scene/Profile/MeProfileViewModel.swift +++ b/Mastodon/Scene/Profile/MeProfileViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-30. // -import os.log import UIKit import Combine import CoreData @@ -25,8 +24,6 @@ final class MeProfileViewModel: ProfileViewModel { $me .sink { [weak self] me in - os_log("%{public}s[%{public}ld], %{public}s: current active mastodon user: %s", ((#file as NSString).lastPathComponent), #line, #function, me?.username ?? "") - guard let self = self else { return } self.user = me } diff --git a/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift b/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift index 27c539d18..b01b69a1c 100644 --- a/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift +++ b/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-29. // -import os.log import UIKit import Combine import XLPagerTabStrip @@ -58,9 +57,6 @@ final class ProfilePagingViewController: ButtonBarPagerTabStripViewController, T return true } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Profile/Paging/ProfilePagingViewModel.swift b/Mastodon/Scene/Profile/Paging/ProfilePagingViewModel.swift index 9b9e78d98..1bf3df83d 100644 --- a/Mastodon/Scene/Profile/Paging/ProfilePagingViewModel.swift +++ b/Mastodon/Scene/Profile/Paging/ProfilePagingViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-29. // -import os.log import UIKit import MastodonAsset import MastodonLocalization @@ -43,8 +42,5 @@ final class ProfilePagingViewModel: NSObject { ] } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 03b9986a2..7bc1d117d 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-2-23. // -import os.log import UIKit import Combine import MastodonMeta @@ -27,8 +26,6 @@ final class ProfileViewController: UIViewController, NeedsDependency, MediaPrevi public static let containerViewMarginForRegularHorizontalSizeClass: CGFloat = 64 public static let containerViewMarginForCompactHorizontalSizeClass: CGFloat = 16 - let logger = Logger(subsystem: "ProfileViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -153,9 +150,6 @@ final class ProfileViewController: UIViewController, NeedsDependency, MediaPrevi profileHeaderViewController.titleView } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -528,19 +522,16 @@ extension ProfileViewController { extension ProfileViewController { @objc private func cancelEditingBarButtonItemPressed(_ sender: UIBarButtonItem) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) viewModel.isEditing = false } @objc private func settingBarButtonItemPressed(_ sender: UIBarButtonItem) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) guard let setting = context.settingService.currentSetting.value else { return } let settingsViewModel = SettingsViewModel(context: context, authContext: viewModel.authContext, setting: setting) _ = coordinator.present(scene: .settings(viewModel: settingsViewModel), from: self, transition: .modal(animated: true, completion: nil)) } @objc private func shareBarButtonItemPressed(_ sender: UIBarButtonItem) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) guard let user = viewModel.user else { return } let record: ManagedObjectRecord = .init(objectID: user.objectID) Task { @@ -562,19 +553,16 @@ extension ProfileViewController { } @objc private func favoriteBarButtonItemPressed(_ sender: UIBarButtonItem) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) let favoriteViewModel = FavoriteViewModel(context: context, authContext: viewModel.authContext) _ = coordinator.present(scene: .favorite(viewModel: favoriteViewModel), from: self, transition: .show) } @objc private func bookmarkBarButtonItemPressed(_ sender: UIBarButtonItem) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) let bookmarkViewModel = BookmarkViewModel(context: context, authContext: viewModel.authContext) _ = coordinator.present(scene: .bookmark(viewModel: bookmarkViewModel), from: self, transition: .show) } @objc private func replyBarButtonItemPressed(_ sender: UIBarButtonItem) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) guard let mastodonUser = viewModel.user else { return } let mention = "@" + mastodonUser.acct UITextChecker.learnWord(mention) @@ -589,15 +577,11 @@ extension ProfileViewController { } @objc private func followedTagsItemPressed(_ sender: UIBarButtonItem) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - let followedTagsViewModel = FollowedTagsViewModel(context: context, authContext: viewModel.authContext) _ = coordinator.present(scene: .followedTags(viewModel: followedTagsViewModel), from: self, transition: .show) } @objc private func refreshControlValueChanged(_ sender: RefreshControl) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - if let userTimelineViewController = profilePagingViewController.currentViewController as? UserTimelineViewController { userTimelineViewController.viewModel.stateMachine.enter(UserTimelineViewModel.State.Reloading.self) } @@ -769,11 +753,9 @@ extension ProfileViewController: ProfileHeaderViewControllerDelegate { headerProfileInfo: profileHeaderViewModel.profileInfoEditing, aboutProfileInfo: profileAboutViewModel.profileInfoEditing ) - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update profile info success") self.viewModel.isEditing = false } catch { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update profile info fail: \(error.localizedDescription)") let alertController = UIAlertController( for: error, title: L10n.Common.Alerts.EditProfileFailure.title, @@ -800,7 +782,6 @@ extension ProfileViewController: ProfileHeaderViewControllerDelegate { } switch completion { case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch profile info for edit fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) let alertController = UIAlertController(for: error, title: L10n.Common.Alerts.EditProfileFailure.title, preferredStyle: .alert) let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default, handler: nil) alertController.addAction(okAction) @@ -810,7 +791,6 @@ extension ProfileViewController: ProfileHeaderViewControllerDelegate { transition: .alertController(animated: true, completion: nil) ) case .finished: - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch profile info for edit success", ((#file as NSString).lastPathComponent), #line, #function) // enter editing mode self.viewModel.isEditing.toggle() } diff --git a/Mastodon/Scene/Profile/ProfileViewModel.swift b/Mastodon/Scene/Profile/ProfileViewModel.swift index 063e20c31..012ebf61b 100644 --- a/Mastodon/Scene/Profile/ProfileViewModel.swift +++ b/Mastodon/Scene/Profile/ProfileViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-29. // -import os.log import UIKit import Combine import CoreDataStack @@ -19,8 +18,6 @@ import MastodonUI // please override this base class class ProfileViewModel: NSObject { - let logger = Logger(subsystem: "ProfileViewModel", category: "ViewModel") - typealias UserID = String var disposeBag = Set() @@ -151,11 +148,9 @@ class ProfileViewModel: NSObject { DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in guard let _ = self else { return } pendingRetryPublisher.value = min(2 * delay, 60) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: [Relationship] fetch again due to pending", ((#file as NSString).lastPathComponent), #line, #function) } } } catch { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Relationship] update user relationship failure: \(error.localizedDescription)") } } // end Task } @@ -197,12 +192,10 @@ class ProfileViewModel: NSObject { record: ManagedObjectRecord, authenticationBox: MastodonAuthenticationBox ) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Relationship]> { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Relationship] update user relationship...") let response = try await context.apiService.relationship( records: [record], authenticationBox: authenticationBox ) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Relationship] did update MastodonUser relationship") return response } diff --git a/Mastodon/Scene/Profile/RemoteProfileViewModel.swift b/Mastodon/Scene/Profile/RemoteProfileViewModel.swift index 705d2806f..832c25858 100644 --- a/Mastodon/Scene/Profile/RemoteProfileViewModel.swift +++ b/Mastodon/Scene/Profile/RemoteProfileViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-2. // -import os.log import Foundation import Combine import CoreDataStack @@ -31,11 +30,11 @@ final class RemoteProfileViewModel: ProfileViewModel { .receive(on: DispatchQueue.main) .sink { completion in switch completion { - case .failure(let error): + case .failure(_): // TODO: handle error - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: remote user %s fetch failed: %s", ((#file as NSString).lastPathComponent), #line, #function, userID, error.localizedDescription) + break case .finished: - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: remote user %s fetched", ((#file as NSString).lastPathComponent), #line, #function, userID) + break } } receiveValue: { [weak self] response in guard let self = self else { return } @@ -107,11 +106,11 @@ final class RemoteProfileViewModel: ProfileViewModel { .receive(on: DispatchQueue.main) .sink { completion in switch completion { - case .failure(let error): + case .failure(_): // TODO: handle error - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: remote user %s fetch failed: %s", ((#file as NSString).lastPathComponent), #line, #function, acct, error.localizedDescription) + break case .finished: - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: remote user %s fetched", ((#file as NSString).lastPathComponent), #line, #function, acct) + break } } receiveValue: { [weak self] response in guard let self = self, let value = response.value else { return } diff --git a/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift b/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift index 6cdd6a594..fdb964b30 100644 --- a/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift +++ b/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-29. // -import os.log import UIKit import AVKit import Combine @@ -17,8 +16,6 @@ import MastodonCore final class UserTimelineViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - let logger = Logger(subsystem: "UserTimelineViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -38,9 +35,6 @@ final class UserTimelineViewController: UIViewController, NeedsDependency, Media let cellFrameCache = NSCache() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+State.swift b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+State.swift index 4ed266c2e..cd0110a87 100644 --- a/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+State.swift +++ b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+State.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-30. // -import os.log import Foundation import GameplayKit import MastodonCore @@ -13,9 +12,6 @@ import MastodonSDK extension UserTimelineViewModel { class State: GKState { - - let logger = Logger(subsystem: "UserTimelineViewModel.State", category: "StateMachine") - let id = UUID() weak var viewModel: UserTimelineViewModel? @@ -24,22 +20,11 @@ extension UserTimelineViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -92,9 +77,7 @@ extension UserTimelineViewModel.State { super.didEnter(from: previousState) guard let _ = viewModel, let stateMachine = stateMachine else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading 3s later…", ((#file as NSString).lastPathComponent), #line, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading", ((#file as NSString).lastPathComponent), #line, #function) stateMachine.enter(Loading.self) } } @@ -167,7 +150,6 @@ extension UserTimelineViewModel.State { viewModel.statusFetchedResultsController.statusIDs = statusIDs } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch user timeline fail: \(error.localizedDescription)") await enter(state: Fail.self) } } // end Task diff --git a/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel.swift b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel.swift index 0d85b6807..0c8d634e5 100644 --- a/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel.swift +++ b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-29. // -import os.log import UIKit import GameplayKit import Combine @@ -65,11 +64,6 @@ final class UserTimelineViewModel { ) self.queryFilter = queryFilter } - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension UserTimelineViewModel { diff --git a/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift b/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift index c7f828efa..c9e88484c 100644 --- a/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift +++ b/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-17. // -import os.log import UIKit import GameplayKit import Combine @@ -15,9 +14,6 @@ import MastodonUI import CoreDataStack final class FavoritedByViewController: UIViewController, NeedsDependency { - - let logger = Logger(subsystem: "FavoritedByViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -32,9 +28,6 @@ final class FavoritedByViewController: UIViewController, NeedsDependency { return tableView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -43,13 +36,6 @@ extension FavoritedByViewController { override func viewDidLoad() { super.viewDidLoad() - #if DEBUG - switch viewModel.kind { - case .favoritedBy: break - default: assertionFailure() - } - #endif - title = L10n.Scene.FavoritedBy.title view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor diff --git a/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift b/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift index e4605a02a..369128f3c 100644 --- a/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift +++ b/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-17. // -import os.log import UIKit import GameplayKit import Combine @@ -16,8 +15,6 @@ import CoreDataStack final class RebloggedByViewController: UIViewController, NeedsDependency { - let logger = Logger(subsystem: "RebloggedByViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -31,11 +28,6 @@ final class RebloggedByViewController: UIViewController, NeedsDependency { tableView.backgroundColor = .clear return tableView }() - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension RebloggedByViewController { diff --git a/Mastodon/Scene/Profile/UserLIst/UserListViewModel+State.swift b/Mastodon/Scene/Profile/UserLIst/UserListViewModel+State.swift index c6666c6f5..cb6e9d3fa 100644 --- a/Mastodon/Scene/Profile/UserLIst/UserListViewModel+State.swift +++ b/Mastodon/Scene/Profile/UserLIst/UserListViewModel+State.swift @@ -5,15 +5,12 @@ // Created by MainasuK on 2022-5-17. // -import os.log import Foundation import GameplayKit import MastodonSDK extension UserListViewModel { class State: GKState { - - let logger = Logger(subsystem: "UserListViewModel.State", category: "StateMachine") let id = UUID() @@ -23,22 +20,10 @@ extension UserListViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -91,9 +76,7 @@ extension UserListViewModel.State { super.didEnter(from: previousState) guard let _ = viewModel, let stateMachine = stateMachine else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading 3s later…", ((#file as NSString).lastPathComponent), #line, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading", ((#file as NSString).lastPathComponent), #line, #function) stateMachine.enter(Loading.self) } } @@ -156,8 +139,6 @@ extension UserListViewModel.State { ) } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch \(response.value.count) accounts") - var hasNewAppend = false var userIDs = viewModel.userFetchedResultsController.userIDs for user in response.value { @@ -177,7 +158,6 @@ extension UserListViewModel.State { viewModel.userFetchedResultsController.userIDs = userIDs } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch following fail: \(error.localizedDescription)") await enter(state: Fail.self) } } // end Task diff --git a/Mastodon/Scene/Profile/UserLIst/UserListViewModel.swift b/Mastodon/Scene/Profile/UserLIst/UserListViewModel.swift index 481ac8ea0..d27562b94 100644 --- a/Mastodon/Scene/Profile/UserLIst/UserListViewModel.swift +++ b/Mastodon/Scene/Profile/UserLIst/UserListViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-17. // -import os.log import UIKit import Combine import CoreDataStack @@ -13,7 +12,6 @@ import GameplayKit import MastodonCore final class UserListViewModel { - let logger = Logger(subsystem: "UserListViewModel", category: "ViewModel") var disposeBag = Set() // input diff --git a/Mastodon/Scene/Report/Report/ReportViewController.swift b/Mastodon/Scene/Report/Report/ReportViewController.swift index fb0417a7f..468fa5ae6 100644 --- a/Mastodon/Scene/Report/Report/ReportViewController.swift +++ b/Mastodon/Scene/Report/Report/ReportViewController.swift @@ -5,7 +5,6 @@ // Created by ihugo on 2021/4/20. // -import os.log import UIKit import Combine import CoreDataStack @@ -15,8 +14,6 @@ import MastodonLocalization class ReportViewController: UIViewController, NeedsDependency, ReportViewControllerAppearance { - let logger = Logger(subsystem: "ReportViewController", category: "ViewController") - var disposeBag = Set() private var observations = Set() @@ -31,9 +28,6 @@ class ReportViewController: UIViewController, NeedsDependency, ReportViewControl action: #selector(ReportViewController.cancelBarButtonItemDidPressed(_:)) ) - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -162,7 +156,6 @@ extension ReportViewController: ReportSupplementaryViewControllerDelegate { Task { @MainActor in do { let _ = try await viewModel.report() - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): report success") let reportResultViewModel = ReportResultViewModel( context: context, diff --git a/Mastodon/Scene/Report/Report/ReportViewModel.swift b/Mastodon/Scene/Report/Report/ReportViewModel.swift index 05f1cfef8..cb840d213 100644 --- a/Mastodon/Scene/Report/Report/ReportViewModel.swift +++ b/Mastodon/Scene/Report/Report/ReportViewModel.swift @@ -12,7 +12,6 @@ import Foundation import GameplayKit import MastodonSDK import OrderedCollections -import os.log import UIKit import MastodonCore import MastodonLocalization diff --git a/Mastodon/Scene/Report/ReportReason/ReportReasonViewController.swift b/Mastodon/Scene/Report/ReportReason/ReportReasonViewController.swift index 517873abe..2bfb689d0 100644 --- a/Mastodon/Scene/Report/ReportReason/ReportReasonViewController.swift +++ b/Mastodon/Scene/Report/ReportReason/ReportReasonViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-10. // -import os.log import UIKit import SwiftUI import Combine @@ -20,8 +19,6 @@ protocol ReportReasonViewControllerDelegate: AnyObject { final class ReportReasonViewController: UIViewController, NeedsDependency, ReportViewControllerAppearance { - let logger = Logger(subsystem: "ReportReasonViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -38,9 +35,6 @@ final class ReportReasonViewController: UIViewController, NeedsDependency, Repor return navigationActionView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -91,8 +85,6 @@ extension ReportReasonViewController { extension ReportReasonViewController { @objc private func nextButtonPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - assert(viewModel.delegate != nil) viewModel.delegate?.reportReasonViewController(self, nextButtonPressed: sender) } diff --git a/Mastodon/Scene/Report/ReportResult/ReportResultViewController.swift b/Mastodon/Scene/Report/ReportResult/ReportResultViewController.swift index 1d67ad6c3..d66eadfd7 100644 --- a/Mastodon/Scene/Report/ReportResult/ReportResultViewController.swift +++ b/Mastodon/Scene/Report/ReportResult/ReportResultViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-2-8. // -import os.log import UIKit import SwiftUI import Combine @@ -38,9 +37,6 @@ final class ReportResultViewController: UIViewController, NeedsDependency, Repor return navigationActionView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Report/ReportResult/ReportResultViewModel.swift b/Mastodon/Scene/Report/ReportResult/ReportResultViewModel.swift index 9caaeeb59..de987b512 100644 --- a/Mastodon/Scene/Report/ReportResult/ReportResultViewModel.swift +++ b/Mastodon/Scene/Report/ReportResult/ReportResultViewModel.swift @@ -10,7 +10,6 @@ import CoreData import CoreDataStack import Foundation import MastodonSDK -import os.log import UIKit import MastodonAsset import MastodonCore diff --git a/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewController.swift b/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewController.swift index 00be4d800..5d9f8ede8 100644 --- a/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewController.swift +++ b/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-10. // -import os.log import UIKit import SwiftUI import Combine @@ -19,8 +18,6 @@ protocol ReportServerRulesViewControllerDelegate: AnyObject { } final class ReportServerRulesViewController: UIViewController, NeedsDependency, ReportViewControllerAppearance { - - let logger = Logger(subsystem: "ReportReasonViewController", category: "ViewController") weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -44,9 +41,6 @@ final class ReportServerRulesViewController: UIViewController, NeedsDependency, return navigationActionView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -101,8 +95,6 @@ extension ReportServerRulesViewController { } @objc private func nextButtonPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - assert(viewModel.delegate != nil) viewModel.delegate?.reportServerRulesViewController(self, nextButtonPressed: sender) } diff --git a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewController.swift b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewController.swift index 3385a12ef..65e7046d0 100644 --- a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewController.swift +++ b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-10. // -import os.log import UIKit import Combine import CoreDataStack @@ -20,9 +19,6 @@ protocol ReportStatusViewControllerDelegate: AnyObject { } class ReportStatusViewController: UIViewController, NeedsDependency, ReportViewControllerAppearance { - - let logger = Logger(subsystem: "ReportStatusViewController", category: "ViewController") - var disposeBag = Set() private var observations = Set() @@ -58,9 +54,6 @@ class ReportStatusViewController: UIViewController, NeedsDependency, ReportViewC return navigationActionView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -136,16 +129,12 @@ extension ReportStatusViewController { } @objc private func skipButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - assert(viewModel.delegate != nil) viewModel.isSkip = true viewModel.delegate?.reportStatusViewController(self, skipButtonDidPressed: sender) } @objc private func nextButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - assert(viewModel.delegate != nil) viewModel.isSkip = false viewModel.delegate?.reportStatusViewController(self, nextButtonDidPressed: sender) diff --git a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+State.swift b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+State.swift index 79807cf0f..d4fb507b2 100644 --- a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+State.swift +++ b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+State.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-2-7. // -import os.log import func QuartzCore.CACurrentMediaTime import Foundation import CoreData @@ -15,8 +14,6 @@ import GameplayKit extension ReportStatusViewModel { class State: GKState { - let logger = Logger(subsystem: "ReportViewModel.State", category: "StateMachine") - let id = UUID() var name: String { @@ -29,20 +26,10 @@ extension ReportStatusViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - let previousState = previousState as? ReportStatusViewModel.State - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] enter \(self.name), previous: \(previousState?.name ?? "")") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(self.name)") - } } } @@ -117,7 +104,6 @@ extension ReportStatusViewModel.State { viewModel.statusFetchedResultsController.statusIDs = statusIDs } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch user timeline fail: \(error.localizedDescription)") await enter(state: Fail.self) } } diff --git a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel.swift b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel.swift index c1c79af48..8c41e1ce0 100644 --- a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel.swift +++ b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel.swift @@ -12,7 +12,6 @@ import Foundation import GameplayKit import MastodonSDK import OrderedCollections -import os.log import UIKit import MastodonCore diff --git a/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewController.swift b/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewController.swift index a84a3a650..8292d69cf 100644 --- a/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewController.swift +++ b/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-2-7. // -import os.log import UIKit import Combine import MastodonAsset @@ -20,8 +19,6 @@ protocol ReportSupplementaryViewControllerDelegate: AnyObject { final class ReportSupplementaryViewController: UIViewController, NeedsDependency, ReportViewControllerAppearance { - let logger = Logger(subsystem: "ReportSupplementaryViewController", category: "ViewController") - var disposeBag = Set() private var observations = Set() @@ -63,9 +60,6 @@ final class ReportSupplementaryViewController: UIViewController, NeedsDependency return navigationActionView }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -134,16 +128,12 @@ extension ReportSupplementaryViewController { } @objc func skipButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - assert(viewModel.delegate != nil) viewModel.isSkip = true viewModel.delegate?.reportSupplementaryViewController(self, skipButtonDidPressed: sender) } @objc func nextButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - assert(viewModel.delegate != nil) viewModel.isSkip = false viewModel.delegate?.reportSupplementaryViewController(self, nextButtonDidPressed: sender) diff --git a/Mastodon/Scene/Report/Share/Cell/ReportStatusTableViewCell+ViewModel.swift b/Mastodon/Scene/Report/Share/Cell/ReportStatusTableViewCell+ViewModel.swift index 9ce759a2a..00d079cfa 100644 --- a/Mastodon/Scene/Report/Share/Cell/ReportStatusTableViewCell+ViewModel.swift +++ b/Mastodon/Scene/Report/Share/Cell/ReportStatusTableViewCell+ViewModel.swift @@ -27,7 +27,6 @@ extension ReportStatusTableViewCell { if statusView.frame == .zero { // set status view width statusView.frame.size.width = tableView.frame.width - ReportStatusTableViewCell.checkboxLeadingMargin - ReportStatusTableViewCell.checkboxSize.width - ReportStatusTableViewCell.statusViewLeadingSpacing - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): did layout for new cell") } statusView.configure(status: viewModel.value) diff --git a/Mastodon/Scene/Report/Share/Cell/ReportStatusTableViewCell.swift b/Mastodon/Scene/Report/Share/Cell/ReportStatusTableViewCell.swift index 6a2cf7fb2..76c7cbfc8 100644 --- a/Mastodon/Scene/Report/Share/Cell/ReportStatusTableViewCell.swift +++ b/Mastodon/Scene/Report/Share/Cell/ReportStatusTableViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-2-7. // -import os.log import UIKit import Combine import MastodonUI @@ -19,8 +18,6 @@ final class ReportStatusTableViewCell: UITableViewCell { var disposeBag = Set() - let logger = Logger(subsystem: "ReportStatusTableViewCell", category: "View") - let checkbox: UIImageView = { let imageView = UIImageView() imageView.preferredSymbolConfiguration = UIImage.SymbolConfiguration(textStyle: .body) diff --git a/Mastodon/Scene/Root/ContentSplitViewController.swift b/Mastodon/Scene/Root/ContentSplitViewController.swift index a10f0ed9b..877bd48d8 100644 --- a/Mastodon/Scene/Root/ContentSplitViewController.swift +++ b/Mastodon/Scene/Root/ContentSplitViewController.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-10-28. // -import os.log import UIKit import Combine import CoreDataStack @@ -46,9 +45,6 @@ final class ContentSplitViewController: UIViewController, NeedsDependency { return mainTabBarController }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift index 4f637c68d..abc2b6bbb 100644 --- a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift +++ b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-1-27. // -import os.log import UIKit import Combine import CoreDataStack @@ -17,8 +16,6 @@ import MastodonUI class MainTabBarController: UITabBarController { - let logger = Logger(subsystem: "MainTabBarController", category: "UI") - public var disposeBag = Set() weak var context: AppContext! @@ -412,7 +409,6 @@ extension MainTabBarController { @objc private func tabBarLongPressGestureRecognizerHandler(_ sender: UILongPressGestureRecognizer) { guard sender.state == .began else { return } guard let tab = touchedTab(by: sender) else { return } - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): long press \(tab.title) tab") switch tab { case .me: @@ -662,8 +658,7 @@ extension MainTabBarController { @objc private func switchToTabKeyCommandHandler(_ sender: UIKeyCommand) { guard let rawValue = sender.propertyList as? Int, let tab = Tab(rawValue: rawValue) else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: %s", ((#file as NSString).lastPathComponent), #line, #function, tab.title) - + guard let index = Tab.allCases.firstIndex(of: tab) else { return } let previousTab = Tab(rawValue: selectedIndex) selectedIndex = index @@ -689,14 +684,12 @@ extension MainTabBarController { } @objc private func showFavoritesKeyCommandHandler(_ sender: UIKeyCommand) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) guard let authContext = self.authContext else { return } let favoriteViewModel = FavoriteViewModel(context: context, authContext: authContext) _ = coordinator.present(scene: .favorite(viewModel: favoriteViewModel), from: nil, transition: .show) } @objc private func openSettingsKeyCommandHandler(_ sender: UIKeyCommand) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) guard let authContext = self.authContext else { return } guard let setting = context.settingService.currentSetting.value else { return } let settingsViewModel = SettingsViewModel(context: context, authContext: authContext, setting: setting) @@ -704,7 +697,6 @@ extension MainTabBarController { } @objc private func composeNewPostKeyCommandHandler(_ sender: UIKeyCommand) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) guard let authContext = self.authContext else { return } let composeViewModel = ComposeViewModel( context: context, diff --git a/Mastodon/Scene/Root/RootSplitViewController.swift b/Mastodon/Scene/Root/RootSplitViewController.swift index a06e055db..dd8dd3a74 100644 --- a/Mastodon/Scene/Root/RootSplitViewController.swift +++ b/Mastodon/Scene/Root/RootSplitViewController.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-9-22. // -import os.log import UIKit import Combine import CoreDataStack @@ -78,9 +77,6 @@ final class RootSplitViewController: UISplitViewController, NeedsDependency { fatalError("init(coder:) has not been implemented") } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift b/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift index 2d5a80200..dab9f1af4 100644 --- a/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift +++ b/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-9-22. // -import os.log import UIKit import Combine import CoreDataStack @@ -19,9 +18,6 @@ protocol SidebarViewControllerDelegate: AnyObject { } final class SidebarViewController: UIViewController, NeedsDependency { - - let logger = Logger(subsystem: "SidebarViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -126,8 +122,7 @@ extension SidebarViewController { let contentHeight = secondaryCollectionView.contentSize.height guard contentHeight > 0 else { return } - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): secondaryCollectionView contentSize: \(secondaryCollectionView.contentSize.debugDescription)") - + let currentFrameHeight = secondaryCollectionView.frame.height guard currentFrameHeight < contentHeight else { return } @@ -171,7 +166,6 @@ extension SidebarViewController { @objc private func sidebarLongPressGestureRecognizerHandler(_ sender: UILongPressGestureRecognizer) { guard sender.state == .began else { return } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") assert(sender.view === collectionView) let position = sender.location(in: collectionView) @@ -185,7 +179,6 @@ extension SidebarViewController { @objc private func sidebarDoubleTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { guard sender.state == .ended else { return } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") assert(sender.view === collectionView) let position = sender.location(in: collectionView) diff --git a/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift b/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift index 7182a443e..fcd6f817c 100644 --- a/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift +++ b/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-9-24. // -import os.log import UIKit import MetaTextKit import FLAnimatedImage @@ -15,8 +14,6 @@ import MastodonAsset final class SidebarListContentView: UIView, UIContentView { - let logger = Logger(subsystem: "SidebarListContentView", category: "UI") - let imageView = UIImageView() let avatarButton: CircleAvatarButton = { let button = CircleAvatarButton() @@ -89,8 +86,6 @@ extension SidebarListContentView { } private func apply(configuration: ContentConfiguration) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - guard currentConfiguration != configuration else { return } currentConfiguration = configuration @@ -157,17 +152,13 @@ extension SidebarListContentView { } struct ContentConfiguration: UIContentConfiguration, Hashable { - let logger = Logger(subsystem: "SidebarListContentView.ContentConfiguration", category: "ContentConfiguration") - var item: Item? func makeContentView() -> UIView & UIContentView { SidebarListContentView(configuration: self) } - func updated(for state: UIConfigurationState) -> ContentConfiguration { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - + func updated(for state: UIConfigurationState) -> ContentConfiguration { var updatedConfiguration = self if let state = state as? UICellConfigurationState { diff --git a/Mastodon/Scene/Search/Search/SearchViewController.swift b/Mastodon/Scene/Search/Search/SearchViewController.swift index 093976e63..9f755cf15 100644 --- a/Mastodon/Scene/Search/Search/SearchViewController.swift +++ b/Mastodon/Scene/Search/Search/SearchViewController.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/3/31. // -import os.log import Combine import GameplayKit import MastodonSDK diff --git a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift index f61b47265..da9771327 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-7-13. // -import os.log import UIKit import Combine import MastodonAsset diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistorySectionHeaderCollectionReusableView.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistorySectionHeaderCollectionReusableView.swift index 6375f5d29..8a68308ae 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistorySectionHeaderCollectionReusableView.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistorySectionHeaderCollectionReusableView.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-20. // -import os.log import UIKit import MastodonAsset import MastodonLocalization diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift index 8645da5ac..9dbbe986e 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-7-13. // -import os.log import UIKit import Combine import CoreDataStack diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewModel.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewModel.swift index 5078895c0..d1360efc4 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewModel.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewModel.swift @@ -8,7 +8,6 @@ import UIKit import Combine import CoreDataStack -import CommonOSLog import MastodonCore final class SearchHistoryViewModel { diff --git a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultSection.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultSection.swift index 0629762de..32a913587 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultSection.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultSection.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/4/6. // -import os.log import Foundation import MastodonSDK import UIKit diff --git a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift index fa8b844a6..0fa2cd4bb 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-7-14. // -import os.log import UIKit import Combine import CoreDataStack diff --git a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel.swift index f66921535..c3ddc2f0a 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel.swift @@ -10,7 +10,6 @@ import Combine import CoreData import CoreDataStack import GameplayKit -import CommonOSLog import MastodonSDK import MastodonCore diff --git a/Mastodon/Scene/Settings/SettingsViewController.swift b/Mastodon/Scene/Settings/SettingsViewController.swift index cf113cf27..910317b9f 100644 --- a/Mastodon/Scene/Settings/SettingsViewController.swift +++ b/Mastodon/Scene/Settings/SettingsViewController.swift @@ -5,7 +5,6 @@ // Created by ihugo on 2021/4/7. // -import os.log import UIKit import Combine import CoreData @@ -128,12 +127,6 @@ class SettingsViewController: UIViewController, NeedsDependency { view.addArrangedSubview(tableFooterLabel) return view }() - - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s:", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension SettingsViewController { @@ -570,26 +563,7 @@ extension SettingsViewController { } @objc private func closeSettingsWindowKeyCommandHandler(_ sender: UIKeyCommand) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) dismiss(animated: true, completion: nil) } } - -#if canImport(SwiftUI) && DEBUG -import SwiftUI - -struct SettingsViewController_Previews: PreviewProvider { - - static var previews: some View { - Group { - UIViewControllerPreview { () -> UIViewController in - return SettingsViewController() - } - .previewLayout(.fixed(width: 390, height: 844)) - } - } - -} - -#endif diff --git a/Mastodon/Scene/Settings/SettingsViewModel.swift b/Mastodon/Scene/Settings/SettingsViewModel.swift index bcf637b4c..945d67f56 100644 --- a/Mastodon/Scene/Settings/SettingsViewModel.swift +++ b/Mastodon/Scene/Settings/SettingsViewModel.swift @@ -11,7 +11,6 @@ import CoreDataStack import Foundation import MastodonSDK import UIKit -import os.log import AuthenticationServices import MastodonCore @@ -63,12 +62,10 @@ class SettingsViewModel { .sink { [weak self] completion in guard let self = self else { return } switch completion { - case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch instance fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) + case .failure(_): self.currentInstance.value = nil case .finished: - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch instance success", ((#file as NSString).lastPathComponent), #line, #function) - + break } } receiveValue: { [weak self] response in guard let self = self else { return } @@ -76,11 +73,6 @@ class SettingsViewModel { } .store(in: &disposeBag) } - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s:", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension SettingsViewModel { diff --git a/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift b/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift index eb55dc575..34d5b3622 100644 --- a/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift +++ b/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/3/11. // -import os.log import Foundation import Combine import UIKit @@ -200,7 +199,6 @@ extension ContentWarningOverlayView { extension ContentWarningOverlayView { @objc private func tapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.contentWarningOverlayViewDidPressed(self) } } diff --git a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift index 6c8c82527..f0b86dd54 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/1/27. // -import os.log import UIKit import Combine import MastodonAsset diff --git a/Mastodon/Scene/Share/View/TableviewCell/StatusThreadRootTableViewCell+ViewModel.swift b/Mastodon/Scene/Share/View/TableviewCell/StatusThreadRootTableViewCell+ViewModel.swift index 9568aa80e..568552c16 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/StatusThreadRootTableViewCell+ViewModel.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/StatusThreadRootTableViewCell+ViewModel.swift @@ -32,7 +32,6 @@ extension StatusThreadRootTableViewCell { if statusView.frame == .zero { // set status view width statusView.frame.size.width = tableView.frame.width - containerViewHorizontalMargin - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): did layout for new cell") } switch viewModel.value { diff --git a/Mastodon/Scene/Share/View/TableviewCell/StatusThreadRootTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/StatusThreadRootTableViewCell.swift index ac86e6aa1..54a38308b 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/StatusThreadRootTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/StatusThreadRootTableViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-17. // -import os.log import UIKit import Combine import MastodonAsset @@ -16,8 +15,6 @@ final class StatusThreadRootTableViewCell: UITableViewCell { static let marginForRegularHorizontalSizeClass: CGFloat = 64 - let logger = Logger(subsystem: "StatusThreadRootTableViewCell", category: "View") - weak var delegate: StatusTableViewCellDelegate? var disposeBag = Set() @@ -44,9 +41,6 @@ final class StatusThreadRootTableViewCell: UITableViewCell { _init() } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift index d3abb9e79..13030122c 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-13. // -import os.log import UIKit import Combine import MastodonAsset @@ -134,7 +133,6 @@ extension ThreadReplyLoaderTableViewCell { extension ThreadReplyLoaderTableViewCell { @objc private func loadMoreButtonDidPressed(_ sender: UIButton) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) delegate?.threadReplyLoaderTableViewCell(self, loadMoreButtonDidPressed: sender) } } diff --git a/Mastodon/Scene/Share/Webview/WebViewController.swift b/Mastodon/Scene/Share/Webview/WebViewController.swift index 209ee483d..b4f45c436 100644 --- a/Mastodon/Scene/Share/Webview/WebViewController.swift +++ b/Mastodon/Scene/Share/Webview/WebViewController.swift @@ -7,7 +7,6 @@ import Foundation import Combine -import os.log import UIKit import WebKit import MastodonCore @@ -28,8 +27,6 @@ final class WebViewController: UIViewController, NeedsDependency { }() deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", (#file as NSString).lastPathComponent, #line, #function) - // cleanup cookie let httpCookieStore = webView.configuration.websiteDataStore.httpCookieStore httpCookieStore.getAllCookies { cookies in diff --git a/Mastodon/Scene/Thread/MastodonStatusThreadViewModel.swift b/Mastodon/Scene/Thread/MastodonStatusThreadViewModel.swift index 97998fd73..ad69791b2 100644 --- a/Mastodon/Scene/Thread/MastodonStatusThreadViewModel.swift +++ b/Mastodon/Scene/Thread/MastodonStatusThreadViewModel.swift @@ -6,7 +6,6 @@ // Copyright © 2021 Twidere. All rights reserved. // -import os.log import Foundation import Combine import CoreData @@ -72,9 +71,6 @@ final class MastodonStatusThreadViewModel { .store(in: &disposeBag) } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -94,7 +90,6 @@ extension MastodonStatusThreadViewModel { dictionary[status.id] = status } } catch { - os_log("%{public}s[%{public}ld], %{public}s: fetch conversation fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) return } @@ -133,7 +128,6 @@ extension MastodonStatusThreadViewModel { dictionary[status.id] = status } } catch { - os_log("%{public}s[%{public}ld], %{public}s: fetch conversation fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) return } diff --git a/Mastodon/Scene/Thread/RemoteThreadViewModel.swift b/Mastodon/Scene/Thread/RemoteThreadViewModel.swift index e22b11961..696e10492 100644 --- a/Mastodon/Scene/Thread/RemoteThreadViewModel.swift +++ b/Mastodon/Scene/Thread/RemoteThreadViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-12. // -import os.log import UIKit import CoreDataStack import MastodonCore diff --git a/Mastodon/Scene/Thread/ThreadViewController.swift b/Mastodon/Scene/Thread/ThreadViewController.swift index c18e41bca..f8abc4c1f 100644 --- a/Mastodon/Scene/Thread/ThreadViewController.swift +++ b/Mastodon/Scene/Thread/ThreadViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-12. // -import os.log import UIKit import Combine import CoreData @@ -18,8 +17,6 @@ import MastodonLocalization final class ThreadViewController: UIViewController, NeedsDependency, MediaPreviewableViewController { - let logger = Logger(subsystem: "ThreadViewController", category: "ViewController") - weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } @@ -47,11 +44,6 @@ final class ThreadViewController: UIViewController, NeedsDependency, MediaPrevie return tableView }() - - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s:", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension ThreadViewController { @@ -112,7 +104,6 @@ extension ThreadViewController { extension ThreadViewController { @objc private func replyBarButtonItemPressed(_ sender: UIBarButtonItem) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") guard case let .root(threadContext) = viewModel.root else { return } let composeViewModel = ComposeViewModel( context: context, diff --git a/Mastodon/Scene/Thread/ThreadViewModel+Diffable.swift b/Mastodon/Scene/Thread/ThreadViewModel+Diffable.swift index d1814436f..aa5f33cec 100644 --- a/Mastodon/Scene/Thread/ThreadViewModel+Diffable.swift +++ b/Mastodon/Scene/Thread/ThreadViewModel+Diffable.swift @@ -116,10 +116,7 @@ extension ThreadViewModel { let hasChanges = newSnapshot.itemIdentifiers != oldSnapshot.itemIdentifiers if !hasChanges && !self.hasPendingStatusEditReload { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): snapshot not changes") return - } else { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): snapshot has changes") } guard let difference = self.calculateReloadSnapshotDifference( @@ -128,12 +125,9 @@ extension ThreadViewModel { newSnapshot: newSnapshot ) else { await self.updateDataSource(snapshot: newSnapshot, animatingDifferences: false) - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): applied new snapshot without tweak") return } - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Snapshot] oldSnapshot: \(oldSnapshot.itemIdentifiers.debugDescription)") - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Snapshot] newSnapshot: \(newSnapshot.itemIdentifiers.debugDescription)") await self.updateSnapshotUsingReloadData( tableView: tableView, oldSnapshot: oldSnapshot, @@ -206,7 +200,6 @@ extension ThreadViewModel { let additionalInset = round(tableView.contentSize.height - cell.frame.maxY) tableView.contentInset.bottom = max(0, bottomSpacing - additionalInset) - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): content inset bottom: \(tableView.contentInset.bottom)") } // set scroll position @@ -219,7 +212,6 @@ extension ThreadViewModel { } return offset }() - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): applied new snapshot") } } diff --git a/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift b/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift index 6d26b9fa4..09411e88a 100644 --- a/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift +++ b/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-12. // -import os.log import Foundation import Combine import GameplayKit @@ -15,8 +14,6 @@ import MastodonSDK extension ThreadViewModel { class LoadThreadState: GKState { - let logger = Logger(subsystem: "ThreadViewModel.LoadThreadState", category: "StateMachine") - let id = UUID() weak var viewModel: ThreadViewModel? @@ -25,22 +22,10 @@ extension ThreadViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: LoadThreadState.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -95,16 +80,7 @@ extension ThreadViewModel.LoadThreadState { from: response.value.ancestors ) ) - // deprecated: Tree mode replies - // viewModel.mastodonStatusThreadViewModel.appendDescendant( - // domain: threadContext.domain, - // nodes: MastodonStatusThreadViewModel.Node.children( - // of: threadContext.statusID, - // from: response.value.descendants - // ) - // ) - - // new: the same order from API + viewModel.mastodonStatusThreadViewModel.appendDescendant( domain: threadContext.domain, nodes: response.value.descendants.map { status in @@ -112,7 +88,6 @@ extension ThreadViewModel.LoadThreadState { } ) } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch status context for \(threadContext.statusID) fail: \(error.localizedDescription)") await enter(state: Fail.self) } } // end Task diff --git a/Mastodon/Scene/Thread/ThreadViewModel.swift b/Mastodon/Scene/Thread/ThreadViewModel.swift index 74afa44dd..69dc73e48 100644 --- a/Mastodon/Scene/Thread/ThreadViewModel.swift +++ b/Mastodon/Scene/Thread/ThreadViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-12. // -import os.log import UIKit import Combine import CoreData @@ -19,8 +18,6 @@ import MastodonLocalization class ThreadViewModel { - let logger = Logger(subsystem: "ThreadViewModel", category: "ViewModel") - var disposeBag = Set() var rootItemObserver: AnyCancellable? @@ -107,9 +104,6 @@ class ThreadViewModel { .store(in: &disposeBag) } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } diff --git a/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift b/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift index ce9cfca96..032034a1f 100644 --- a/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift +++ b/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-28. // -import os.log import UIKit import func AVFoundation.AVMakeRect @@ -307,7 +306,6 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning { // finish or cancel current transitioning let targetPosition = completionPosition() - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: target position: %s", ((#file as NSString).lastPathComponent), #line, #function, targetPosition == .end ? "end" : "start") isTransitionContextFinish = true animate(targetPosition) @@ -330,7 +328,6 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning { updateTransitionItemPosition(of: translation) case .ended, .cancelled: let targetPosition = completionPosition() - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: target position: %s", ((#file as NSString).lastPathComponent), #line, #function, targetPosition == .end ? "end" : "start") isTransitionContextFinish = true animate(targetPosition) diff --git a/Mastodon/Scene/Transition/MediaPreview/MediaPreviewTransitionController.swift b/Mastodon/Scene/Transition/MediaPreview/MediaPreviewTransitionController.swift index d8d822bc5..b418f084c 100644 --- a/Mastodon/Scene/Transition/MediaPreview/MediaPreviewTransitionController.swift +++ b/Mastodon/Scene/Transition/MediaPreview/MediaPreviewTransitionController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-28. // -import os.log import UIKit final class MediaPreviewTransitionController: NSObject { @@ -37,7 +36,6 @@ extension MediaPreviewTransitionController { guard let mediaPreviewViewController = self.mediaPreviewViewController else { return } wantsInteractiveStart = true mediaPreviewViewController.dismiss(animated: true, completion: nil) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: start interactive dismiss", ((#file as NSString).lastPathComponent), #line, #function) } } @@ -116,8 +114,6 @@ extension MediaPreviewTransitionController: UIViewControllerTransitioningDelegat extension MediaPreviewTransitionController: ViewControllerAnimatedTransitioningDelegate { func animationEnded(_ transitionCompleted: Bool) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: completed: %s", ((#file as NSString).lastPathComponent), #line, #function, transitionCompleted.description) - dismissInteractiveTransitioning = nil wantsInteractiveStart = false } diff --git a/Mastodon/Scene/Transition/Search/SearchToSearchDetailViewControllerAnimatedTransitioning.swift b/Mastodon/Scene/Transition/Search/SearchToSearchDetailViewControllerAnimatedTransitioning.swift index e060acc83..683ba6336 100644 --- a/Mastodon/Scene/Transition/Search/SearchToSearchDetailViewControllerAnimatedTransitioning.swift +++ b/Mastodon/Scene/Transition/Search/SearchToSearchDetailViewControllerAnimatedTransitioning.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-7-13. // -import os.log import UIKit final class SearchToSearchDetailViewControllerAnimatedTransitioning: ViewControllerAnimatedTransitioning { @@ -17,11 +16,6 @@ final class SearchToSearchDetailViewControllerAnimatedTransitioning: ViewControl self.transitionDuration = 0.2 } - - deinit { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } - } // MARK: - UIViewControllerAnimatedTransitioning diff --git a/Mastodon/Scene/Transition/ViewControllerAnimatedTransitioning.swift b/Mastodon/Scene/Transition/ViewControllerAnimatedTransitioning.swift index 71fd199f4..7089f17eb 100644 --- a/Mastodon/Scene/Transition/ViewControllerAnimatedTransitioning.swift +++ b/Mastodon/Scene/Transition/ViewControllerAnimatedTransitioning.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-28. // -import os.log import UIKit protocol ViewControllerAnimatedTransitioningDelegate: AnyObject { @@ -29,11 +28,6 @@ class ViewControllerAnimatedTransitioning: NSObject { self.transitionDuration = 0.3 super.init() } - - deinit { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } - } // MARK: - UIViewControllerAnimatedTransitioning diff --git a/Mastodon/Supporting Files/AppDelegate.swift b/Mastodon/Supporting Files/AppDelegate.swift index 79eaeb5cd..24479418b 100644 --- a/Mastodon/Supporting Files/AppDelegate.swift +++ b/Mastodon/Supporting Files/AppDelegate.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021/1/22. // -import os.log import UIKit import UserNotifications import AVFoundation @@ -79,15 +78,11 @@ extension AppDelegate: UNUserNotificationCenterDelegate { willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void ) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: [Push Notification]", ((#file as NSString).lastPathComponent), #line, #function) guard let pushNotification = AppDelegate.mastodonPushNotification(from: notification) else { completionHandler([]) return } - let notificationID = String(pushNotification.notificationID) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: [Push Notification] notification %s", ((#file as NSString).lastPathComponent), #line, #function, notificationID) - let accessToken = pushNotification.accessToken UserDefaults.shared.increaseNotificationCount(accessToken: accessToken) appContext.notificationService.applicationIconBadgeNeedsUpdate.send() @@ -110,15 +105,12 @@ extension AppDelegate: UNUserNotificationCenterDelegate { didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void ) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: [Push Notification]", ((#file as NSString).lastPathComponent), #line, #function) - + guard let pushNotification = AppDelegate.mastodonPushNotification(from: response.notification) else { completionHandler() return } - let notificationID = String(pushNotification.notificationID) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: [Push Notification] notification %s", ((#file as NSString).lastPathComponent), #line, #function, notificationID) appContext.notificationService.handle(pushNotification: pushNotification) appContext.notificationService.requestRevealNotificationPublisher.send(pushNotification) completionHandler() diff --git a/Mastodon/Supporting Files/SceneDelegate.swift b/Mastodon/Supporting Files/SceneDelegate.swift index 1e023227c..0ef979926 100644 --- a/Mastodon/Supporting Files/SceneDelegate.swift +++ b/Mastodon/Supporting Files/SceneDelegate.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021/1/22. // -import os.log import UIKit import Combine import CoreDataStack @@ -14,10 +13,6 @@ import MastodonExtension import MastodonUI import MastodonSDK -#if PROFILE -import FPSIndicator -#endif - class SceneDelegate: UIResponder, UIWindowSceneDelegate { var disposeBag = Set() @@ -26,14 +21,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? var coordinator: SceneCoordinator? - #if PROFILE - var fpsIndicator: FPSIndicator? - #endif - var savedShortCutItem: UIApplicationShortcutItem? - let logger = Logger(subsystem: "SceneDelegate", category: "logic") - func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = scene as? UIWindowScene else { return } @@ -102,10 +91,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { #endif } .store(in: &observations) - - #if PROFILE - fpsIndicator = FPSIndicator(windowScene: windowScene) - #endif } func sceneDidBecomeActive(_ scene: UIScene) { @@ -204,7 +189,6 @@ extension SceneDelegate { @MainActor private func handler(shortcutItem: UIApplicationShortcutItem) async -> Bool { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(shortcutItem.type)") switch shortcutItem.type { case NotificationService.unreadShortcutItemIdentifier: @@ -236,11 +220,9 @@ extension SceneDelegate { case "org.joinmastodon.app.search": coordinator?.switchToTabBar(tab: .search) - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): select search tab") if let searchViewController = coordinator?.tabBarController.topMost as? SearchViewController { searchViewController.searchBarTapPublisher.send("") - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): trigger search") } default: @@ -260,7 +242,6 @@ extension SceneDelegate { private func showComposeViewController() { if coordinator?.tabBarController.topMost is ComposeViewController { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): composing…") } else { if let authContext = coordinator?.authContext { let composeViewModel = ComposeViewModel( @@ -270,9 +251,6 @@ extension SceneDelegate { destination: .topLevel ) _ = coordinator?.present(scene: .compose(viewModel: composeViewModel), from: nil, transition: .modal(animated: true, completion: nil)) - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): present compose scene") - } else { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): not authenticated") } } } diff --git a/MastodonSDK/Package.swift b/MastodonSDK/Package.swift index 12aadd888..7b44f806d 100644 --- a/MastodonSDK/Package.swift +++ b/MastodonSDK/Package.swift @@ -36,18 +36,15 @@ let package = Package( dependencies: [ .package(name: "ArkanaKeys", path: "../dependencies/ArkanaKeys"), .package(url: "https://github.com/will-lumley/FaviconFinder.git", from: "3.2.2"), - .package(url: "https://github.com/siteline/SwiftUI-Introspect.git", from: "0.1.3"), .package(url: "https://github.com/MainasuK/UITextView-Placeholder.git", from: "1.4.1"), .package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.4.0"), .package(url: "https://github.com/Alamofire/AlamofireImage.git", from: "4.1.0"), .package(url: "https://github.com/apple/swift-collections.git", from: "1.0.3"), - .package(url: "https://github.com/apple/swift-nio.git", from: "1.0.0"), + .package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"), .package(url: "https://github.com/Flipboard/FLAnimatedImage.git", from: "1.0.0"), .package(url: "https://github.com/kean/Nuke-FLAnimatedImage-Plugin.git", from: "8.0.0"), .package(url: "https://github.com/kean/Nuke.git", from: "10.3.1"), .package(url: "https://github.com/kishikawakatsumi/KeychainAccess.git", from: "4.2.2"), - .package(url: "https://github.com/MainasuK/CommonOSLog", from: "0.1.1"), - .package(url: "https://github.com/MainasuK/FPSIndicator.git", from: "1.0.0"), .package(url: "https://github.com/slackhq/PanModal.git", from: "1.2.7"), .package(url: "https://github.com/TimOliver/TOCropViewController.git", from: "2.6.1"), .package(url: "https://github.com/TwidereProject/MetaTextKit.git", exact: "2.2.5"), @@ -93,7 +90,6 @@ let package = Package( "MastodonSDK", .product(name: "Alamofire", package: "Alamofire"), .product(name: "AlamofireImage", package: "AlamofireImage"), - .product(name: "CommonOSLog", package: "CommonOSLog"), .product(name: "ArkanaKeys", package: "ArkanaKeys"), .product(name: "KeychainAccess", package: "KeychainAccess"), .product(name: "MetaTextKit", package: "MetaTextKit") @@ -120,7 +116,6 @@ let package = Package( .product(name: "FLAnimatedImage", package: "FLAnimatedImage"), .product(name: "FaviconFinder", package: "FaviconFinder"), .product(name: "Nuke", package: "Nuke"), - .product(name: "Introspect", package: "SwiftUI-Introspect"), .product(name: "UITextView+Placeholder", package: "UITextView-Placeholder"), .product(name: "UIHostingConfigurationBackport", package: "UIHostingConfigurationBackport"), .product(name: "TabBarPager", package: "TabBarPager"), diff --git a/MastodonSDK/Sources/CoreDataStack/CoreDataStack.swift b/MastodonSDK/Sources/CoreDataStack/CoreDataStack.swift index f7d8f1de7..720e5df85 100644 --- a/MastodonSDK/Sources/CoreDataStack/CoreDataStack.swift +++ b/MastodonSDK/Sources/CoreDataStack/CoreDataStack.swift @@ -13,8 +13,6 @@ import MastodonCommon public final class CoreDataStack { - static let logger = Logger(subsystem: "CoreDataStack", category: "DB") - private(set) var storeDescriptions: [NSPersistentStoreDescription] public let didFinishLoad = CurrentValueSubject(false) @@ -82,7 +80,6 @@ public final class CoreDataStack { (reason == "Can't find mapping model for migration" || reason == "Persistent store migration failed, missing mapping model.") { if let storeDescription = container.persistentStoreDescriptions.first, let url = storeDescription.url { try? container.persistentStoreCoordinator.destroyPersistentStore(at: url, ofType: NSSQLiteStoreType, options: nil) - os_log("%{public}s[%{public}ld], %{public}s: cannot migrate model. rebuild database…", ((#file as NSString).lastPathComponent), #line, #function) } else { assertionFailure() } @@ -95,9 +92,7 @@ public final class CoreDataStack { // it's looks like the remote notification only trigger when app enter and leave background container.viewContext.automaticallyMergesChangesFromParent = true - - os_log("%{public}s[%{public}ld], %{public}s: %s", ((#file as NSString).lastPathComponent), #line, #function, storeDescription.debugDescription) - + callback() #if DEBUG @@ -108,9 +103,7 @@ public final class CoreDataStack { formatter.allowedUnits = [.useMB] formatter.countStyle = .file let size = formatter.string(fromByteCount: Int64(data.count)) - CoreDataStack.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): Database size: \(size)") } catch { - CoreDataStack.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): Cannot get database size") } #endif }) diff --git a/MastodonSDK/Sources/CoreDataStack/Extension/NSManagedObjectContext.swift b/MastodonSDK/Sources/CoreDataStack/Extension/NSManagedObjectContext.swift index 3b4818992..97604a735 100644 --- a/MastodonSDK/Sources/CoreDataStack/Extension/NSManagedObjectContext.swift +++ b/MastodonSDK/Sources/CoreDataStack/Extension/NSManagedObjectContext.swift @@ -28,7 +28,6 @@ extension NSManagedObjectContext { } catch { rollback() - os_log("%{public}s[%{public}ld], %{public}s: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) throw error } } diff --git a/MastodonSDK/Sources/MastodonCore/AppContext.swift b/MastodonSDK/Sources/MastodonCore/AppContext.swift index 02966e2f8..e99002a9d 100644 --- a/MastodonSDK/Sources/MastodonCore/AppContext.swift +++ b/MastodonSDK/Sources/MastodonCore/AppContext.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 22/9/30. // -import os.log import UIKit import SwiftUI import Combine @@ -129,9 +128,6 @@ public class AppContext: ObservableObject { .store(in: &disposeBag) } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -163,7 +159,6 @@ extension AppContext { ImageDownloader.defaultURLCache().removeAllCachedResponses() let currentDiskBytes = ImageDownloader.defaultURLCache().currentDiskUsage let purgedDiskBytes = max(0, diskBytes - currentDiskBytes) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: purge AlamofireImage cache bytes: %ld -> %ld (%ld)", ((#file as NSString).lastPathComponent), #line, #function, diskBytes, currentDiskBytes, purgedDiskBytes) promise(.success(purgedDiskBytes)) } } diff --git a/MastodonSDK/Sources/MastodonCore/AppSecret.swift b/MastodonSDK/Sources/MastodonCore/AppSecret.swift index c409a2761..9493e1c7d 100644 --- a/MastodonSDK/Sources/MastodonCore/AppSecret.swift +++ b/MastodonSDK/Sources/MastodonCore/AppSecret.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-27. // - import Foundation import CryptoKit import KeychainAccess diff --git a/MastodonSDK/Sources/MastodonCore/AuthContext.swift b/MastodonSDK/Sources/MastodonCore/AuthContext.swift index ff936c3c0..cd11c49cb 100644 --- a/MastodonSDK/Sources/MastodonCore/AuthContext.swift +++ b/MastodonSDK/Sources/MastodonCore/AuthContext.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 22/10/8. // -import os.log import Foundation import Combine import CoreDataStack @@ -19,8 +18,6 @@ public class AuthContext { var disposeBag = Set() - let logger = Logger(subsystem: "AuthContext", category: "AuthContext") - // Mastodon public private(set) var mastodonAuthenticationBox: MastodonAuthenticationBox diff --git a/MastodonSDK/Sources/MastodonCore/Extension/CoreDataStack/SubscriptionAlerts.swift b/MastodonSDK/Sources/MastodonCore/Extension/CoreDataStack/SubscriptionAlerts.swift index edf2df0c9..962ca85bf 100644 --- a/MastodonSDK/Sources/MastodonCore/Extension/CoreDataStack/SubscriptionAlerts.swift +++ b/MastodonSDK/Sources/MastodonCore/Extension/CoreDataStack/SubscriptionAlerts.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-25. // - import Foundation import CoreDataStack import MastodonSDK diff --git a/MastodonSDK/Sources/MastodonCore/Extension/FileManager.swift b/MastodonSDK/Sources/MastodonCore/Extension/FileManager.swift index 9a7ee6601..02942a6a2 100644 --- a/MastodonSDK/Sources/MastodonCore/Extension/FileManager.swift +++ b/MastodonSDK/Sources/MastodonCore/Extension/FileManager.swift @@ -5,12 +5,10 @@ // Created by MainasuK on 2022-1-15. // -import os.log import Foundation extension FileManager { - static let logger = Logger(subsystem: "FileManager", category: "File") - + public func createTemporaryFileURL( filename: String, pathExtension: String @@ -20,8 +18,6 @@ extension FileManager { .appendingPathComponent(filename) .appendingPathExtension(pathExtension) try FileManager.default.createDirectory(at: tempDirectoryURL, withIntermediateDirectories: true, attributes: nil) - - Self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): create temporary file at: \(fileURL.debugDescription)") return fileURL } diff --git a/MastodonSDK/Sources/MastodonCore/Extension/NSItemProvider.swift b/MastodonSDK/Sources/MastodonCore/Extension/NSItemProvider.swift index c5b8d513c..672adb81e 100644 --- a/MastodonSDK/Sources/MastodonCore/Extension/NSItemProvider.swift +++ b/MastodonSDK/Sources/MastodonCore/Extension/NSItemProvider.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2021/11/19. // -import os.log import Foundation import UniformTypeIdentifiers import MobileCoreServices @@ -16,8 +15,6 @@ import PhotosUI extension NSItemProvider { - static let logger = Logger(subsystem: "NSItemProvider", category: "Logic") - public struct ImageLoadResult { public let data: Data public let type: UTType? @@ -84,9 +81,6 @@ extension NSItemProvider { CGImageDestinationAddImage(imageDestination, cgImage, destinationProperties) CGImageDestinationFinalize(imageDestination) - let dataSize = ByteCountFormatter.string(fromByteCount: Int64(data.length), countStyle: .memory) - NSItemProvider.logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): load image \(dataSize)") - let result = ImageLoadResult( data: data as Data, type: cgImage.utType.flatMap { UTType($0 as String) } diff --git a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/FeedFetchedResultsController.swift b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/FeedFetchedResultsController.swift index 2ba2ec5cb..682c83815 100644 --- a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/FeedFetchedResultsController.swift +++ b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/FeedFetchedResultsController.swift @@ -6,7 +6,6 @@ // Copyright © 2021 Twidere. All rights reserved. // -import os.log import Foundation import UIKit import Combine @@ -20,8 +19,6 @@ final public class FeedFetchedResultsController: NSObject { static let defaultFetchLimit = 100 } - public let logger = Logger(subsystem: "FeedFetchedResultsController", category: "DB") - var disposeBag = Set() private let fetchedResultsController: NSFetchedResultsController diff --git a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/FollowedTagsFetchedResultController.swift b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/FollowedTagsFetchedResultController.swift index 8c5c64b58..4c3670283 100644 --- a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/FollowedTagsFetchedResultController.swift +++ b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/FollowedTagsFetchedResultController.swift @@ -5,7 +5,6 @@ // Created by Marcus Kida on 23.11.22. // -import os.log import UIKit import Combine import CoreData @@ -69,7 +68,6 @@ public final class FollowedTagsFetchedResultController: NSObject { // MARK: - NSFetchedResultsControllerDelegate extension FollowedTagsFetchedResultController: NSFetchedResultsControllerDelegate { public func controller(_ controller: NSFetchedResultsController, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) let objects = fetchedResultsController.fetchedObjects ?? [] self.records = objects diff --git a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/SearchHistoryFetchedResultController.swift b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/SearchHistoryFetchedResultController.swift index 196c9b8f5..f8376a9c0 100644 --- a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/SearchHistoryFetchedResultController.swift +++ b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/SearchHistoryFetchedResultController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-7-15. // -import os.log import UIKit import Combine import CoreData @@ -71,7 +70,6 @@ public final class SearchHistoryFetchedResultController: NSObject { // MARK: - NSFetchedResultsControllerDelegate extension SearchHistoryFetchedResultController: NSFetchedResultsControllerDelegate { public func controller(_ controller: NSFetchedResultsController, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) let objects = fetchedResultsController.fetchedObjects ?? [] self._objectIDs.value = objects.map { $0.objectID } diff --git a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/SettingFetchedResultController.swift b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/SettingFetchedResultController.swift index cd8845386..a51d9501b 100644 --- a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/SettingFetchedResultController.swift +++ b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/SettingFetchedResultController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-25. // -import os.log import UIKit import Combine import CoreData @@ -56,7 +55,6 @@ public final class SettingFetchedResultController: NSObject { // MARK: - NSFetchedResultsControllerDelegate extension SettingFetchedResultController: NSFetchedResultsControllerDelegate { public func controller(_ controller: NSFetchedResultsController, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) let objects = fetchedResultsController.fetchedObjects ?? [] self.settings.value = objects diff --git a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/StatusFetchedResultsController.swift b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/StatusFetchedResultsController.swift index bb4184bfc..1bc5426c6 100644 --- a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/StatusFetchedResultsController.swift +++ b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/StatusFetchedResultsController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-30. // -import os.log import UIKit import Combine import CoreData diff --git a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/UserFetchedResultsController.swift b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/UserFetchedResultsController.swift index cf4f1fc07..452fa2914 100644 --- a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/UserFetchedResultsController.swift +++ b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/UserFetchedResultsController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-7-7. // -import os.log import UIKit import Combine import CoreData diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Card.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Card.swift index 9ab8a817c..e390d8e35 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Card.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Card.swift @@ -9,7 +9,6 @@ import CoreData import CoreDataStack import Foundation import MastodonSDK -import os.log extension Persistence.Card { @@ -17,7 +16,6 @@ extension Persistence.Card { public let domain: String public let entity: Mastodon.Entity.Card public let me: MastodonUser? - public let log = Logger(subsystem: "Card", category: "Persistence") public init( domain: String, entity: Mastodon.Entity.Card, @@ -40,14 +38,6 @@ extension Persistence.Card { self.card = card self.isNewInsertion = isNewInsertion } - - #if DEBUG - public let logger = Logger(subsystem: "Persistence.MastodonCard.PersistResult", category: "Persist") - public func log() { - let pollInsertionFlag = isNewInsertion ? "+" : "-" - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(pollInsertionFlag)](\(card.title)):") - } - #endif } public static func create( diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+MastodonUser.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+MastodonUser.swift index 8571a11cf..b8b5f3089 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+MastodonUser.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+MastodonUser.swift @@ -10,7 +10,6 @@ import CoreData import CoreDataStack import Foundation import MastodonSDK -import os.log extension Persistence.MastodonUser { @@ -19,7 +18,6 @@ extension Persistence.MastodonUser { public let entity: Mastodon.Entity.Account public let cache: Persistence.PersistCache? public let networkDate: Date - public let log = Logger(subsystem: "MastodonUser", category: "Persistence") public init( domain: String, @@ -127,7 +125,6 @@ extension Persistence.MastodonUser { public let entity: Mastodon.Entity.Relationship public let me: MastodonUser public let networkDate: Date - public let log = Logger(subsystem: "MastodonUser", category: "Persistence") public init( entity: Mastodon.Entity.Relationship, diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Notification.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Notification.swift index 5273d2bbf..cfe715503 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Notification.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Notification.swift @@ -9,7 +9,6 @@ import CoreData import CoreDataStack import Foundation import MastodonSDK -import os.log import class CoreDataStack.Notification extension Persistence.Notification { @@ -19,7 +18,6 @@ extension Persistence.Notification { public let entity: Mastodon.Entity.Notification public let me: MastodonUser public let networkDate: Date - public let log = Logger(subsystem: "Notification", category: "Persistence") public init( domain: String, diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Poll.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Poll.swift index 6e9d5a436..c0d6c813c 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Poll.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Poll.swift @@ -9,7 +9,6 @@ import CoreData import CoreDataStack import Foundation import MastodonSDK -import os.log extension Persistence.Poll { @@ -18,7 +17,6 @@ extension Persistence.Poll { public let entity: Mastodon.Entity.Poll public let me: MastodonUser? public let networkDate: Date - public let log = Logger(subsystem: "Poll", category: "Persistence") public init( domain: String, entity: Mastodon.Entity.Poll, @@ -43,14 +41,6 @@ extension Persistence.Poll { self.poll = poll self.isNewInsertion = isNewInsertion } - - #if DEBUG - public let logger = Logger(subsystem: "Persistence.MastodonPoll.PersistResult", category: "Persist") - public func log() { - let pollInsertionFlag = isNewInsertion ? "+" : "-" - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(pollInsertionFlag)](\(poll.id)):") - } - #endif } public static func createOrMerge( diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+PollOption.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+PollOption.swift index d26447276..322fd254f 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+PollOption.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+PollOption.swift @@ -9,7 +9,6 @@ import CoreData import CoreDataStack import Foundation import MastodonSDK -import os.log extension Persistence.PollOption { @@ -19,7 +18,6 @@ extension Persistence.PollOption { public let entity: Mastodon.Entity.Poll.Option public let me: MastodonUser? public let networkDate: Date - public let log = Logger(subsystem: "PollOption", category: "Persistence") public init( index: Int, diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+SearchHistory.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+SearchHistory.swift index 84a7bd15f..ef47448cc 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+SearchHistory.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+SearchHistory.swift @@ -9,7 +9,6 @@ import CoreData import CoreDataStack import Foundation import MastodonSDK -import os.log extension Persistence.SearchHistory { @@ -17,7 +16,6 @@ extension Persistence.SearchHistory { public let entity: Entity public let me: MastodonUser public let now: Date - public let log = Logger(subsystem: "SearchHistory", category: "Persistence") public init( entity: Entity, me: MastodonUser, diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift index dbdfd26c0..c7548db82 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift @@ -10,7 +10,6 @@ import CoreData import CoreDataStack import Foundation import MastodonSDK -import os.log extension Persistence.Status { @@ -21,7 +20,6 @@ extension Persistence.Status { public let statusCache: Persistence.PersistCache? public let userCache: Persistence.PersistCache? public let networkDate: Date - public let log = Logger(subsystem: "Status", category: "Persistence") public init( domain: String, @@ -54,16 +52,6 @@ extension Persistence.Status { self.isNewInsertion = isNewInsertion self.isNewInsertionAuthor = isNewInsertionAuthor } - - #if DEBUG - public let logger = Logger(subsystem: "Persistence.Status.PersistResult", category: "Persist") - public func log() { - let statusInsertionFlag = isNewInsertion ? "+" : "-" - let authorInsertionFlag = isNewInsertionAuthor ? "+" : "-" - let contentPreview = status.content.prefix(32).replacingOccurrences(of: "\n", with: " ") - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(statusInsertionFlag)](\(status.id))[\(authorInsertionFlag)](\(status.author.id))@\(status.author.username): \(contentPreview)") - } - #endif } public static func createOrMerge( diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Tag.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Tag.swift index 3071fed0d..163019505 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Tag.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Tag.swift @@ -9,7 +9,6 @@ import CoreData import CoreDataStack import Foundation import MastodonSDK -import os.log extension Persistence.Tag { @@ -18,7 +17,6 @@ extension Persistence.Tag { public let entity: Mastodon.Entity.Tag public let me: MastodonUser? public let networkDate: Date - public let log = Logger(subsystem: "Tag", category: "Persistence") public init( domain: String, diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift index de7f9c3f5..191917476 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift @@ -5,11 +5,9 @@ // Created by MainasuK Cirno on 2021/2/2. // -import os.log import CoreDataStack import Foundation import Combine -import CommonOSLog import MastodonCommon import MastodonSDK @@ -38,7 +36,7 @@ extension APIService { let managedObjectContext = self.backgroundManagedObjectContext try await managedObjectContext.performChanges { - let result = Persistence.MastodonUser.createOrMerge( + _ = Persistence.MastodonUser.createOrMerge( in: managedObjectContext, context: Persistence.MastodonUser.PersistContext( domain: domain, @@ -47,10 +45,6 @@ extension APIService { networkDate: response.networkDate ) ) - - let flag = result.isNewInsertion ? "+" : "-" - let logger = Logger(subsystem: "APIService", category: "AccountInfo") - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch mastodon user [\(flag)](\(response.value.id))\(response.value.username)") } return response @@ -70,12 +64,11 @@ extension APIService { authorization: authorization ) .flatMap { response -> AnyPublisher, Error> in - let logger = Logger(subsystem: "Account", category: "API") let account = response.value let managedObjectContext = self.backgroundManagedObjectContext return managedObjectContext.performChanges { - let result = Persistence.MastodonUser.createOrMerge( + _ = Persistence.MastodonUser.createOrMerge( in: managedObjectContext, context: Persistence.MastodonUser.PersistContext( domain: domain, @@ -84,8 +77,6 @@ extension APIService { networkDate: response.networkDate ) ) - let flag = result.isNewInsertion ? "+" : "-" - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): mastodon user [\(flag)](\(result.user.id))\(result.user.username) verifed") } .setFailureType(to: Error.self) .tryMap { result -> Mastodon.Response.Content in @@ -106,8 +97,6 @@ extension APIService { query: Mastodon.API.Account.UpdateCredentialQuery, authorization: Mastodon.API.OAuth.Authorization ) async throws -> Mastodon.Response.Content { - let logger = Logger(subsystem: "Account", category: "API") - let response = try await Mastodon.API.Account.updateCredentials( session: session, domain: domain, @@ -117,7 +106,7 @@ extension APIService { let managedObjectContext = self.backgroundManagedObjectContext try await managedObjectContext.performChanges { - let result = Persistence.MastodonUser.createOrMerge( + _ = Persistence.MastodonUser.createOrMerge( in: managedObjectContext, context: Persistence.MastodonUser.PersistContext( domain: domain, @@ -126,10 +115,6 @@ extension APIService { networkDate: response.networkDate ) ) - let flag = result.isNewInsertion ? "+" : "-" - let userID = response.value.id - let username = response.value.username - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): mastodon user [\(flag)](\(userID)\(username) verifed") } return response diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Block.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Block.swift index 5580245ce..45543dd1f 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Block.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Block.swift @@ -9,7 +9,6 @@ import UIKit import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { @@ -65,7 +64,6 @@ extension APIService { user: ManagedObjectRecord, authenticationBox: MastodonAuthenticationBox ) async throws -> Mastodon.Response.Content { - let logger = Logger(subsystem: "APIService", category: "Block") let managedObjectContext = backgroundManagedObjectContext let blockContext: MastodonBlockContext = try await managedObjectContext.performChanges { @@ -87,7 +85,7 @@ extension APIService { // will do block action. set to unfollow user.update(isFollowing: false, by: me) } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user[\(user.id)](\(user.username)) block state: \(!isBlocking)") + return MastodonBlockContext( sourceUserID: me.id, targetUserID: user.id, @@ -118,7 +116,6 @@ extension APIService { } } catch { result = .failure(error) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user[\(blockContext.targetUserID)](\(blockContext.targetUsername)) block failure: \(error.localizedDescription)") } try await managedObjectContext.performChanges { @@ -141,12 +138,10 @@ extension APIService { networkDate: response.networkDate ) ) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user[\(blockContext.targetUserID)](\(blockContext.targetUsername)) block state: \(relationship.blocking)") case .failure: // rollback user.update(isBlocking: blockContext.isBlocking, by: me) user.update(isFollowing: blockContext.isFollowing, by: me) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] rollback user[\(blockContext.targetUserID)](\(blockContext.targetUsername)) block state") } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Bookmark.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Bookmark.swift index 9020524ea..8c4e48417 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Bookmark.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Bookmark.swift @@ -10,7 +10,6 @@ import Combine import MastodonSDK import CoreData import CoreDataStack -import CommonOSLog extension APIService { @@ -23,8 +22,7 @@ extension APIService { record: ManagedObjectRecord, authenticationBox: MastodonAuthenticationBox ) async throws -> Mastodon.Response.Content { - let logger = Logger(subsystem: "APIService", category: "Bookmark") - + let managedObjectContext = backgroundManagedObjectContext // update bookmark state and retrieve bookmark context @@ -45,7 +43,6 @@ extension APIService { statusID: status.id, isBookmarked: isBookmarked ) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status bookmark: \(!isBookmarked)") return context } @@ -62,7 +59,6 @@ extension APIService { result = .success(response) } catch { result = .failure(error) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update bookmark failure: \(error.localizedDescription)") } // update bookmark state @@ -89,11 +85,9 @@ extension APIService { networkDate: response.networkDate ) ) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status bookmark: \(response.value.bookmarked.debugDescription)") case .failure: // rollback status.update(bookmarked: bookmarkContext.isBookmarked, by: me) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): rollback status bookmark") } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+CustomEmoji.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+CustomEmoji.swift index 647bb4956..2586da81a 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+CustomEmoji.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+CustomEmoji.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+DomainBlock.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+DomainBlock.swift index 138997500..3bfa519c7 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+DomainBlock.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+DomainBlock.swift @@ -6,7 +6,6 @@ // import Combine -import CommonOSLog import CoreData import CoreDataStack import Foundation diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Favorite.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Favorite.swift index 166118c8a..ec44afa93 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Favorite.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Favorite.swift @@ -5,13 +5,11 @@ // Created by sxiaojian on 2021/2/8. // - import Foundation import Combine import MastodonSDK import CoreData import CoreDataStack -import CommonOSLog extension APIService { @@ -25,8 +23,7 @@ extension APIService { record: ManagedObjectRecord, authenticationBox: MastodonAuthenticationBox ) async throws -> Mastodon.Response.Content { - let logger = Logger(subsystem: "APIService", category: "Favorite") - + let managedObjectContext = backgroundManagedObjectContext // update like state and retrieve like context @@ -51,7 +48,6 @@ extension APIService { isFavorited: isFavorited, favoritedCount: favoritedCount ) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status favorite: \(!isFavorited), \(favoriteCount)") return context } @@ -68,7 +64,6 @@ extension APIService { result = .success(response) } catch { result = .failure(error) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update favorite failure: \(error.localizedDescription)") } // update like state @@ -98,12 +93,10 @@ extension APIService { if favoriteContext.isFavorited { status.update(favouritesCount: max(0, status.favouritesCount - 1)) // undo API return count has delay. Needs -1 local } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status favorite: \(response.value.favourited.debugDescription)") case .failure: // rollback status.update(liked: favoriteContext.isFavorited, by: me) status.update(favouritesCount: favoriteContext.favoritedCount) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): rollback status favorite") } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Filter.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Filter.swift index 01f8087a2..28806363b 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Filter.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Filter.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-7-9. // -import os.log import Combine import CoreData import CoreDataStack diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Follow.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Follow.swift index 0cd71cb2e..8decfe632 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Follow.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Follow.swift @@ -9,7 +9,6 @@ import UIKit import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { @@ -34,8 +33,7 @@ extension APIService { user: ManagedObjectRecord, authenticationBox: MastodonAuthenticationBox ) async throws -> Mastodon.Response.Content { - let logger = Logger(subsystem: "APIService", category: "Follow") - + let managedObjectContext = backgroundManagedObjectContext let _followContext: MastodonFollowContext? = try await managedObjectContext.performChanges { guard let me = authenticationBox.authentication.user(in: managedObjectContext) else { return nil } @@ -49,17 +47,14 @@ extension APIService { // unfollow user.update(isFollowing: false, by: me) user.update(isFollowRequested: false, by: me) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user friendship: undo follow") } else { // follow if user.locked { user.update(isFollowing: false, by: me) user.update(isFollowRequested: true, by: me) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user friendship: pending follow") } else { user.update(isFollowing: true, by: me) user.update(isFollowRequested: false, by: me) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user friendship: following") } } let context = MastodonFollowContext( @@ -88,7 +83,6 @@ extension APIService { ).singleOutput() result = .success(response) } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update friendship failure: \(error.localizedDescription)") result = .failure(error) } @@ -108,13 +102,10 @@ extension APIService { networkDate: response.networkDate ) ) - let following = response.value.following - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user friendship: following \(following)") case .failure: // rollback user.update(isFollowing: followContext.isFollowing, by: me) user.update(isFollowRequested: followContext.isPending, by: me) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] rollback user friendship") } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+FollowRequest.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+FollowRequest.swift index fb0e52ddb..f90aab5d3 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+FollowRequest.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+FollowRequest.swift @@ -9,7 +9,6 @@ import UIKit import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Follower.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Follower.swift index 9c5801449..f463501f6 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Follower.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Follower.swift @@ -9,7 +9,6 @@ import UIKit import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Following.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Following.swift index e2a2c6142..683a98166 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Following.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Following.swift @@ -9,7 +9,6 @@ import UIKit import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HashtagTimeline.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HashtagTimeline.swift index 86ee7faed..c8d1bfb73 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HashtagTimeline.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HashtagTimeline.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift index ac3c6402a..5317cd4b0 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK public extension Foundation.Notification.Name { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Instance.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Instance.swift index eb39b5585..b5a549903 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Instance.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Instance.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Mute.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Mute.swift index 15cd009e5..65f0eb811 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Mute.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Mute.swift @@ -9,7 +9,6 @@ import UIKit import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { @@ -64,8 +63,7 @@ extension APIService { user: ManagedObjectRecord, authenticationBox: MastodonAuthenticationBox ) async throws -> Mastodon.Response.Content { - let logger = Logger(subsystem: "APIService", category: "Mute") - + let managedObjectContext = backgroundManagedObjectContext let muteContext: MastodonMuteContext = try await managedObjectContext.performChanges { let authentication = authenticationBox.authentication @@ -81,7 +79,6 @@ extension APIService { // toggle mute state user.update(isMuting: !isMuting, by: me) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user[\(user.id)](\(user.username)) mute state: \(!isMuting)") return MastodonMuteContext( sourceUserID: me.id, targetUserID: user.id, @@ -113,7 +110,6 @@ extension APIService { } } catch { result = .failure(error) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user[\(muteContext.targetUserID)](\(muteContext.targetUsername)) mute failure: \(error.localizedDescription)") } try await managedObjectContext.performChanges { @@ -132,11 +128,9 @@ extension APIService { networkDate: response.networkDate ) ) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user[\(muteContext.targetUserID)](\(muteContext.targetUsername)) mute state: \(relationship.muting.debugDescription)") case .failure: // rollback user.update(isMuting: muteContext.isMuting, by: me) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] rollback user[\(muteContext.targetUserID)](\(muteContext.targetUsername)) mute state") } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Poll.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Poll.swift index dba4527a4..ef486448d 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Poll.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Poll.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+PublicTimeline.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+PublicTimeline.swift index 6d6726db9..67d77463a 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+PublicTimeline.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+PublicTimeline.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Reblog.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Reblog.swift index 717f2715d..d3d5e1c15 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Reblog.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Reblog.swift @@ -10,7 +10,6 @@ import Combine import MastodonSDK import CoreData import CoreDataStack -import CommonOSLog extension APIService { @@ -24,7 +23,6 @@ extension APIService { record: ManagedObjectRecord, authenticationBox: MastodonAuthenticationBox ) async throws -> Mastodon.Response.Content { - let logger = Logger(subsystem: "APIService", category: "Reblog") let managedObjectContext = backgroundManagedObjectContext // update repost state and retrieve repost context @@ -47,7 +45,6 @@ extension APIService { isReblogged: isReblogged, rebloggedCount: rebloggedCount ) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status reblog: \(!isReblogged), \(reblogCount)") return reblogContext } guard let reblogContext = _reblogContext else { @@ -67,7 +64,6 @@ extension APIService { result = .success(response) } catch { result = .failure(error) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update reblog failure: \(error.localizedDescription)") } // update repost state @@ -97,12 +93,10 @@ extension APIService { if reblogContext.isReblogged { status.update(reblogsCount: max(0, status.reblogsCount - 1)) // undo API return count has delay. Needs -1 local } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status reblog: \(!reblogContext.isReblogged)") case .failure: // rollback status.update(reblogged: reblogContext.isReblogged, by: me) status.update(reblogsCount: reblogContext.rebloggedCount) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): rollback status reblog") } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Relationship.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Relationship.swift index c2c88cfb1..370ed4fcf 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Relationship.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Relationship.swift @@ -9,7 +9,6 @@ import UIKit import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Search.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Search.swift index 7f63b2419..df607df93 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Search.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Search.swift @@ -8,7 +8,6 @@ import Foundation import Combine import MastodonSDK -import CommonOSLog extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+Publish.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+Publish.swift index ee70db964..0f4896949 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+Publish.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+Publish.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+Translate.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+Translate.swift index a802d6489..483f52431 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+Translate.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status+Translate.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status.swift index d652f0ad4..b67b79349 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Subscriptions.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Subscriptions.swift index 825bdcd4c..c29505785 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Subscriptions.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Subscriptions.swift @@ -5,7 +5,6 @@ // Created by ihugo on 2021/4/9. // -import os.log import Combine import CoreData import CoreDataStack @@ -29,8 +28,6 @@ extension APIService { query: query ) .flatMap { response -> AnyPublisher, Error> in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: create subscription successful %s", ((#file as NSString).lastPathComponent), #line, #function, response.value.endpoint) - let managedObjectContext = self.backgroundManagedObjectContext return managedObjectContext.performChanges { guard let subscription = managedObjectContext.object(with: subscriptionObjectID) as? NotificationSubscription else { @@ -59,8 +56,6 @@ extension APIService { authorization: authorization ).singleOutput() - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: cancel subscription successful", ((#file as NSString).lastPathComponent), #line, #function) - return response } diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Tags.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Tags.swift index b5b526b8a..0a61fc687 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Tags.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Tags.swift @@ -5,7 +5,6 @@ // Created by Marcus Kida on 23.11.22. // -import os.log import Foundation import Combine import CoreData diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Thread.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Thread.swift index ecc7a0bc3..7006a7477 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Thread.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Thread.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-12. // -import os.log import Foundation import Combine import CoreData diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+UserTimeline.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+UserTimeline.swift index 402bd9f61..b661c282b 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+UserTimeline.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+UserTimeline.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+WebFinger.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+WebFinger.swift index b542cbe8d..26d86edf4 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+WebFinger.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+WebFinger.swift @@ -9,7 +9,6 @@ import Foundation import Combine import CoreData import CoreDataStack -import CommonOSLog import MastodonSDK extension APIService { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService.swift index 44eb9938e..0b7b16ea4 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/1/27. // -import os.log import UIKit import Combine import CoreData diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Instance.swift b/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Instance.swift index d9566f6d4..1a76fe4d5 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Instance.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Instance.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-10-9. // -import os.log import Foundation import CoreData import CoreDataStack @@ -17,8 +16,7 @@ extension APIService.CoreData { into managedObjectContext: NSManagedObjectContext, domain: String, entity: Mastodon.Entity.Instance, - networkDate: Date, - log: Logger + networkDate: Date ) -> (instance: Instance, isCreated: Bool) { // fetch old mastodon user let old: Instance? = { diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+InstanceV2.swift b/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+InstanceV2.swift index 19e188133..675ee9b46 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+InstanceV2.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+InstanceV2.swift @@ -1,4 +1,3 @@ -import os.log import Foundation import CoreData import CoreDataStack @@ -10,18 +9,15 @@ extension APIService.CoreData { public let domain: String public let entity: Mastodon.Entity.V2.Instance public let networkDate: Date - public let log: Logger - + public init( domain: String, entity: Mastodon.Entity.V2.Instance, - networkDate: Date, - log: Logger + networkDate: Date ) { self.domain = domain self.entity = entity self.networkDate = networkDate - self.log = log } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Setting.swift b/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Setting.swift index 0c23eab6e..dcdde6965 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Setting.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Setting.swift @@ -5,8 +5,6 @@ // Created by MainasuK Cirno on 2021-4-25. // - -import os.log import Foundation import CoreData import CoreDataStack diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Subscriptions.swift b/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Subscriptions.swift index ec8eec8b2..ea3f4c5f8 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Subscriptions.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/CoreData/APIService+CoreData+Subscriptions.swift @@ -5,7 +5,6 @@ // Created by ihugo on 2021/4/11. // -import os.log import Foundation import CoreData import CoreDataStack diff --git a/MastodonSDK/Sources/MastodonCore/Service/AuthenticationService.swift b/MastodonSDK/Sources/MastodonCore/Service/AuthenticationService.swift index d6024faad..71c619f19 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/AuthenticationService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/AuthenticationService.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021/2/3. // -import os.log import Foundation import Combine import CoreData diff --git a/MastodonSDK/Sources/MastodonCore/Service/Emoji/EmojiService+CustomEmojiViewModel+LoadState.swift b/MastodonSDK/Sources/MastodonCore/Service/Emoji/EmojiService+CustomEmojiViewModel+LoadState.swift index a03af9bd1..e8f76eb84 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/Emoji/EmojiService+CustomEmojiViewModel+LoadState.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/Emoji/EmojiService+CustomEmojiViewModel+LoadState.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-15. // -import os.log import Foundation import GameplayKit @@ -16,10 +15,6 @@ extension EmojiService.CustomEmojiViewModel { init(viewModel: EmojiService.CustomEmojiViewModel) { self.viewModel = viewModel } - - override func didEnter(from previousState: GKState?) { - os_log("%{public}s[%{public}ld], %{public}s: enter %s, previous: %s", ((#file as NSString).lastPathComponent), #line, #function, self.debugDescription, previousState.debugDescription) - } } } @@ -44,14 +39,12 @@ extension EmojiService.CustomEmojiViewModel.LoadState { // .receive(on: DispatchQueue.main) .sink { completion in switch completion { - case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: failed to load custom emojis for %s: %s. Retry 10s later", ((#file as NSString).lastPathComponent), #line, #function, viewModel.domain, error.localizedDescription) + case .failure(_): stateMachine.enter(Fail.self) case .finished: break } } receiveValue: { response in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: load %ld custom emojis for %s", ((#file as NSString).lastPathComponent), #line, #function, response.value.count, viewModel.domain) stateMachine.enter(Finish.self) viewModel.emojis.value = response.value } diff --git a/MastodonSDK/Sources/MastodonCore/Service/Emoji/EmojiService.swift b/MastodonSDK/Sources/MastodonCore/Service/Emoji/EmojiService.swift index f912217d4..2da15c3ef 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/Emoji/EmojiService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/Emoji/EmojiService.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-15. // -import os.log import Foundation import Combine import MastodonSDK diff --git a/MastodonSDK/Sources/MastodonCore/Service/InstanceService.swift b/MastodonSDK/Sources/MastodonCore/Service/InstanceService.swift index 1c3c05d4b..0d1509af8 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/InstanceService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/InstanceService.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-10-9. // -import os.log import Foundation import Combine import CoreData @@ -15,9 +14,7 @@ import MastodonSDK public final class InstanceService { var disposeBag = Set() - - let logger = Logger(subsystem: "InstanceService", category: "Logic") - + // input let backgroundManagedObjectContext: NSManagedObjectContext weak var apiService: APIService? @@ -62,14 +59,7 @@ extension InstanceService { // .flatMap { [unowned self] response -> AnyPublisher in // return // } - .sink { [weak self] completion in - guard let self = self else { return } - switch completion { - case .failure(let error): - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Instance] update instance failure: \(error.localizedDescription)") - case .finished: - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Instance] update instance for domain: \(domain)") - } + .sink { _ in } receiveValue: { [weak self] response in guard let _ = self else { return } // do nothing @@ -85,8 +75,7 @@ extension InstanceService { into: managedObjectContext, domain: domain, entity: response.value, - networkDate: response.networkDate, - log: Logger(subsystem: "Update", category: "InstanceService") + networkDate: response.networkDate ) // update instance @@ -113,8 +102,7 @@ extension InstanceService { context: .init( domain: domain, entity: response.value, - networkDate: response.networkDate, - log: Logger(subsystem: "Update", category: "InstanceService") + networkDate: response.networkDate ) ) @@ -147,9 +135,7 @@ public extension InstanceService { authenticationBox: authBox ) - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Instance] update mutes and blocks succeeded") } catch { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Instance] update mutes and blocks failure: \(error.localizedDescription)") } } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/MastodonAttachment/MastodonAttachmentService+UploadState.swift b/MastodonSDK/Sources/MastodonCore/Service/MastodonAttachment/MastodonAttachmentService+UploadState.swift index c4a403fc9..cb12a3b36 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/MastodonAttachment/MastodonAttachmentService+UploadState.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/MastodonAttachment/MastodonAttachmentService+UploadState.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-18. // -import os.log import Foundation import Combine import GameplayKit @@ -20,7 +19,6 @@ extension MastodonAttachmentService { } public override func didEnter(from previousState: GKState?) { - os_log("%{public}s[%{public}ld], %{public}s: enter %s, previous: %s", ((#file as NSString).lastPathComponent), #line, #function, self.debugDescription, previousState.debugDescription) service?.uploadStateMachineSubject.send(self) } } @@ -86,18 +84,14 @@ extension MastodonAttachmentService.UploadState { { self.needsFallback = true stateMachine.enter(Uploading.self) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: upload attachment fallback to V1", ((#file as NSString).lastPathComponent), #line, #function) } else { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: upload attachment fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) service.error.send(error) stateMachine.enter(Fail.self) } case .finished: - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: upload attachment success", ((#file as NSString).lastPathComponent), #line, #function) break } } receiveValue: { response in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: upload attachment %s success: %s", ((#file as NSString).lastPathComponent), #line, #function, response.value.id, response.value.url ?? "") service.attachment.value = response.value if response.statusCode == 202 { // check if still processing @@ -142,18 +136,15 @@ extension MastodonAttachmentService.UploadState { guard let _ = self else { return } switch completion { case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: get attachment fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) service.error.send(error) stateMachine.enter(Fail.self) case .finished: - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: get attachment success", ((#file as NSString).lastPathComponent), #line, #function) break } } receiveValue: { [weak self] response in guard let self = self else { return } guard let _ = response.value.url else { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { [weak self] in - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: processing, retry in 2s", ((#file as NSString).lastPathComponent), #line, #function) self?.stateMachine?.enter(Processing.self) } return diff --git a/MastodonSDK/Sources/MastodonCore/Service/MastodonAttachment/MastodonAttachmentService.swift b/MastodonSDK/Sources/MastodonCore/Service/MastodonAttachment/MastodonAttachmentService.swift index 1af18efbe..7433e0f8d 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/MastodonAttachment/MastodonAttachmentService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/MastodonAttachment/MastodonAttachmentService.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-17. // -import os.log import UIKit import Combine import PhotosUI @@ -167,7 +166,6 @@ public final class MastodonAttachmentService { let image = UIImage(cgImage: cgImage) return image } catch { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: thumbnail generate fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) return nil } } @@ -176,9 +174,6 @@ public final class MastodonAttachmentService { .store(in: &disposeBag) } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -238,7 +233,6 @@ extension MastodonAttachmentService { let imageData = try Data(contentsOf: url) promise(.success(.jpeg(imageData))) } catch { - os_log("%{public}s[%{public}ld], %{public}s: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) promise(.failure(error)) } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/Notification/NotificationService.swift b/MastodonSDK/Sources/MastodonCore/Service/Notification/NotificationService.swift index 229def922..3485b4888 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/Notification/NotificationService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/Notification/NotificationService.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-22. // -import os.log import UIKit import Combine import CoreData @@ -52,17 +51,6 @@ public final class NotificationService { }) .store(in: &disposeBag) - deviceToken - .receive(on: DispatchQueue.main) - .sink { [weak self] deviceToken in - guard let _ = self else { return } - guard let deviceToken = deviceToken else { return } - let token = [UInt8](deviceToken).toHexString() - let logger = Logger(subsystem: "DeviceToken", category: "NotificationService") - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): deviceToken: \(token)") - } - .store(in: &disposeBag) - Publishers.CombineLatest( authenticationService.$mastodonAuthenticationBoxes, applicationIconBadgeNeedsUpdate @@ -94,7 +82,6 @@ extension NotificationService { let center = UNUserNotificationCenter.current() center.requestAuthorization(options: [.alert, .sound, .badge]) { [weak self] granted, error in guard let self = self else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: request notification permission: %s", ((#file as NSString).lastPathComponent), #line, #function, granted ? "granted" : "fail") self.isNotificationPermissionGranted.value = granted @@ -229,9 +216,7 @@ extension NotificationService { domain: domain, authorization: .init(accessToken: userAccessToken) ) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: [Push Notification] cancel sign-out user subscription", ((#file as NSString).lastPathComponent), #line, #function) } catch { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: [Push Notification] failed to cancel sign-out user subscription: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/PhotoLibraryService.swift b/MastodonSDK/Sources/MastodonCore/Service/PhotoLibraryService.swift index 053ab3586..a6a2f721c 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/PhotoLibraryService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/PhotoLibraryService.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-29. // -import os.log import UIKit import Combine import Photos diff --git a/MastodonSDK/Sources/MastodonCore/Service/PublisherService/PublisherService.swift b/MastodonSDK/Sources/MastodonCore/Service/PublisherService/PublisherService.swift index 1c62a38d2..bd14f4b6e 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/PublisherService/PublisherService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/PublisherService/PublisherService.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2021-12-2. // -import os.log import UIKit import Combine @@ -13,8 +12,6 @@ public final class PublisherService { var disposeBag = Set() - let logger = Logger(subsystem: "PublisherService", category: "Service") - // input let apiService: APIService @@ -43,7 +40,6 @@ public final class PublisherService { self.currentPublishProgressObservation = last.progress .observe(\.fractionCompleted, options: [.initial, .new]) { [weak self] progress, _ in guard let self = self else { return } - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): publish progress \(progress.fractionCompleted)") self.currentPublishProgress = progress.fractionCompleted } } @@ -88,19 +84,15 @@ extension PublisherService { Task { do { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): publish status…") let result = try await publisher.publish(api: apiService, authContext: authContext) - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): publish status success") self.statusPublishResult.send(.success(result)) self.statusPublishers.removeAll(where: { $0 === publisher }) } catch is CancellationError { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): publish cancelled") self.statusPublishers.removeAll(where: { $0 === publisher }) } catch { - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): publish failure: \(error.localizedDescription)") self.statusPublishResult.send(.failure(error)) self.currentPublishProgress = 0 } diff --git a/MastodonSDK/Sources/MastodonCore/Service/SettingService.swift b/MastodonSDK/Sources/MastodonCore/Service/SettingService.swift index e86e9e044..3c74045d3 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/SettingService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/SettingService.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-25. // -import os.log import UIKit import Combine import CoreDataStack @@ -109,8 +108,6 @@ public final class SettingService { } .store(in: &disposeBag) - let logger = Logger(subsystem: "Notification", category: "SettingService") - Publishers.CombineLatest3( notificationService.deviceToken, currentSetting.eraseToAnyPublisher(), @@ -154,20 +151,7 @@ public final class SettingService { ) } .debounce(for: .seconds(3), scheduler: DispatchQueue.main) // limit subscribe request emit time interval - .sink(receiveValue: { [weak self] publisher in - guard let self = self else { return } - publisher - .sink { completion in - switch completion { - case .failure(let error): - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Push Notification] subscribe failure: \(error.localizedDescription)") - case .finished: - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Push Notification] subscribe success") - } - } receiveValue: { response in - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): subscribe response: \(response.value.endpoint)") - } - .store(in: &self.disposeBag) + .sink(receiveValue: { _ in }) .store(in: &disposeBag) } @@ -197,7 +181,6 @@ extension SettingService { let themeName: ThemeName = .system if UserDefaults.shared.currentThemeNameRawValue != themeName.rawValue { ThemeService.shared.set(themeName: themeName) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: update theme style", ((#file as NSString).lastPathComponent), #line, #function) } // set avatar mode diff --git a/MastodonSDK/Sources/MastodonCore/Service/StatusFilterService.swift b/MastodonSDK/Sources/MastodonCore/Service/StatusFilterService.swift index e752a022e..6be64bcba 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/StatusFilterService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/StatusFilterService.swift @@ -5,7 +5,6 @@ // Created by Cirno MainasuK on 2021-7-14. // -import os.log import Foundation import Combine import CoreData @@ -75,11 +74,8 @@ public final class StatusFilterService { .sink { result in switch result { case .success(let response): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch account filters success. %ld items", ((#file as NSString).lastPathComponent), #line, #function, response.value.count) self.activeFilters = response.value - case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch account filters fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) - + case .failure(_): break } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/StatusPublishService.swift b/MastodonSDK/Sources/MastodonCore/Service/StatusPublishService.swift index a411f30c2..b92eb291f 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/StatusPublishService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/StatusPublishService.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-26. // -import os.log import Foundation import Intents import Combine @@ -26,54 +25,4 @@ public final class StatusPublishService { // output let composeViewModelDidUpdatePublisher = PassthroughSubject() // let latestPublishingComposeViewModel = CurrentValueSubject(nil) - - init() { -// Publishers.CombineLatest( -// viewModels.eraseToAnyPublisher(), -// composeViewModelDidUpdatePublisher.eraseToAnyPublisher() -// ) -// .map { viewModels, _ in viewModels.last } -// .assign(to: \.value, on: latestPublishingComposeViewModel) -// .store(in: &disposeBag) - } - -} - -extension StatusPublishService { - -// func publish(composeViewModel: ComposeViewModel) { -// workingQueue.sync { -// guard !self.viewModels.value.contains(where: { $0 === composeViewModel }) else { return } -// self.viewModels.value = self.viewModels.value + [composeViewModel] -// -// composeViewModel.publishStateMachinePublisher -// .receive(on: DispatchQueue.main) -// .sink { [weak self, weak composeViewModel] state in -// guard let self = self else { return } -// guard let composeViewModel = composeViewModel else { return } -// -// os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: composeViewModelDidUpdate", ((#file as NSString).lastPathComponent), #line, #function) -// self.composeViewModelDidUpdatePublisher.send() -// -// switch state { -// case is ComposeViewModel.PublishState.Finish: -// self.remove(composeViewModel: composeViewModel) -// default: -// break -// } -// } -// .store(in: &composeViewModel.disposeBag) // cancel subscription when viewModel dealloc -// } -// } -// -// func remove(composeViewModel: ComposeViewModel) { -// workingQueue.async { -// var viewModels = self.viewModels.value -// viewModels.removeAll(where: { $0 === composeViewModel }) -// self.viewModels.value = viewModels -// -// os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: composeViewModel removed", ((#file as NSString).lastPathComponent), #line, #function) -// } -// } - } diff --git a/MastodonSDK/Sources/MastodonCore/Vendor/ItemProviderLoader.swift b/MastodonSDK/Sources/MastodonCore/Vendor/ItemProviderLoader.swift index ad26e0ceb..62bb98041 100644 --- a/MastodonSDK/Sources/MastodonCore/Vendor/ItemProviderLoader.swift +++ b/MastodonSDK/Sources/MastodonCore/Vendor/ItemProviderLoader.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-18. // -import os.log import Foundation import Combine import MobileCoreServices @@ -15,11 +14,6 @@ import MastodonSDK // load image with low memory usage // Refs: https://christianselig.com/2020/09/phpickerviewcontroller-efficiently/ public enum ItemProviderLoader { - static let logger = Logger(subsystem: "ItemProviderLoader", category: "logic") -} - -extension ItemProviderLoader { - public static func loadImageData(from result: PHPickerResult) -> Future { loadImageData(from: result.itemProvider) } @@ -94,9 +88,6 @@ extension ItemProviderLoader { CGImageDestinationAddImage(imageDestination, cgImage, destinationProperties) CGImageDestinationFinalize(imageDestination) - let dataSize = ByteCountFormatter.string(fromByteCount: Int64(data.length), countStyle: .memory) - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): load image \(dataSize)") - let file = Mastodon.Query.MediaAttachment.jpeg(data as Data) promise(.success(file)) } diff --git a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift index 57d99dc41..cba9e91b6 100644 --- a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift +++ b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift @@ -5,7 +5,6 @@ // Created by xiaojian sun on 2021/1/25. // -import os.log import Foundation import enum NIOHTTP1.HTTPResponseStatus diff --git a/MastodonSDK/Sources/MastodonSDK/Query/SerialStream.swift b/MastodonSDK/Sources/MastodonSDK/Query/SerialStream.swift index 5808b9f6d..b8df4f7b9 100644 --- a/MastodonSDK/Sources/MastodonSDK/Query/SerialStream.swift +++ b/MastodonSDK/Sources/MastodonSDK/Query/SerialStream.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-5-28. // -import os.log import Foundation import Combine @@ -16,8 +15,6 @@ import Combine final class SerialStream: NSObject { - let logger = Logger(subsystem: "SerialStream", category: "Stream") - public let progress = Progress() var writingTimerSubscriber: AnyCancellable? @@ -61,8 +58,7 @@ final class SerialStream: NSObject { .sink { [weak self] timer in guard let self = self else { return } guard self.canWrite else { return } - os_log(.debug, "%{public}s[%{public}ld], %{public}s: writing…", ((#file as NSString).lastPathComponent), #line, #function) - + guard self.currentStreamIndex < self.streams.count else { self.boundStreams.output.close() self.writingTimerSubscriber = nil // cancel timer after task completed @@ -78,11 +74,8 @@ final class SerialStream: NSObject { baseAddress += writeResult remainsBytes -= writeResult - os_log(.debug, "%{public}s[%{public}ld], %{public}s: write %ld/%ld bytes. write result: %ld", ((#file as NSString).lastPathComponent), #line, #function, baseAddress, readBytesCount, writeResult) - self.progress.completedUnitCount += Int64(writeResult) - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): estimate progress: \(self.progress.completedUnitCount)/\(self.progress.totalUnitCount)") - + if writeResult == -1 { break } @@ -108,7 +101,6 @@ final class SerialStream: NSObject { let reaminsCount = SerialStream.bufferSize - readBytesCount let readCount = inputStream.read(&self.buffer[readBytesCount], maxLength: reaminsCount) - os_log(.debug, "%{public}s[%{public}ld], %{public}s: read source %ld bytes", ((#file as NSString).lastPathComponent), #line, #function, readCount) switch readCount { case 0: @@ -124,11 +116,6 @@ final class SerialStream: NSObject { } } } - - deinit { - os_log(.debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension SerialStream { @@ -141,8 +128,6 @@ extension SerialStream { // MARK: - StreamDelegate extension SerialStream: StreamDelegate { func stream(_ aStream: Stream, handle eventCode: Stream.Event) { - os_log(.debug, "%{public}s[%{public}ld], %{public}s: eventCode %s", ((#file as NSString).lastPathComponent), #line, #function, String(eventCode.rawValue)) - guard aStream == boundStreams.output else { return } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentView.swift index b44ba1bff..ee3487a4f 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentView.swift @@ -5,14 +5,11 @@ // Created by MainasuK on 2022-5-20. // -import os.log import UIKit import SwiftUI -import Introspect import AVKit import MastodonAsset import MastodonLocalization -import Introspect public struct AttachmentView: View { diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Compress.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Compress.swift index 0f16bdc1d..efcedbc3f 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Compress.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Compress.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022/11/11. // -import os.log import UIKit import AVKit import MastodonCore @@ -92,7 +91,6 @@ extension AttachmentViewModel { DispatchQueue.main.async { [weak self] in guard let self = self else { return } self.videoCompressProgress = Double(progress) - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: export progress: %.2f", ((#file as NSString).lastPathComponent), #line, #function, progress) } }, completionHandler: { result in switch result { @@ -104,7 +102,6 @@ extension AttachmentViewModel { default: if Task.isCancelled { exporter.cancelExport() - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: cancel export", ((#file as NSString).lastPathComponent), #line, #function) } print("NextLevelSessionExporter, did not complete") } @@ -138,10 +135,8 @@ extension AttachmentViewModel { guard let compressedJpegData = image.jpegData(compressionQuality: 0.8) else { throw AttachmentError.invalidAttachmentType } - os_log("%{public}s[%{public}ld], %{public}s: compress png %.2fMiB -> jpeg %.2fMiB", ((#file as NSString).lastPathComponent), #line, #function, Double(imageData.count) / 1024 / 1024, Double(compressedJpegData.count) / 1024 / 1024) imageData = compressedJpegData } else { - os_log("%{public}s[%{public}ld], %{public}s: png %.2fMiB", ((#file as NSString).lastPathComponent), #line, #function, Double(imageData.count) / 1024 / 1024) break } } else { @@ -152,10 +147,8 @@ extension AttachmentViewModel { guard let compressedJpegData = scaledImage.jpegData(compressionQuality: 0.8) else { throw AttachmentError.invalidAttachmentType } - os_log("%{public}s[%{public}ld], %{public}s: compress jpeg %.2fMiB -> jpeg %.2fMiB", ((#file as NSString).lastPathComponent), #line, #function, Double(imageData.count) / 1024 / 1024, Double(compressedJpegData.count) / 1024 / 1024) imageData = compressedJpegData } else { - os_log("%{public}s[%{public}ld], %{public}s: jpeg %.2fMiB", ((#file as NSString).lastPathComponent), #line, #function, Double(imageData.count) / 1024 / 1024) break } } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+DragAndDrop.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+DragAndDrop.swift index a319aec95..3efef5111 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+DragAndDrop.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+DragAndDrop.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022/11/8. // -import os.log import UIKit import Combine import UniformTypeIdentifiers diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Load.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Load.swift index 31c4a59d9..1cdc53cdc 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Load.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Load.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022/11/8. // -import os.log import UIKit import AVKit import UniformTypeIdentifiers @@ -137,7 +136,6 @@ extension AttachmentViewModel { let image = UIImage(cgImage: cgImage) return image } catch { - AttachmentViewModel.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): thumbnail generate fail: \(error.localizedDescription)") return nil } } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Upload.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Upload.swift index aeedb6b51..58259d28c 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Upload.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel+Upload.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2021-11-26. // -import os.log import UIKit import UniformTypeIdentifiers import MastodonCore @@ -143,8 +142,6 @@ extension AttachmentViewModel { let attachmentUploadResponse: Mastodon.Response.Content = try await { do { - AttachmentViewModel.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [V2] upload attachment...") - progress.addChild(query.progress, withPendingUnitCount: uploadTaskCount) return try await context.apiService.uploadMedia( domain: context.authContext.mastodonAuthenticationBox.domain, @@ -158,8 +155,6 @@ extension AttachmentViewModel { apiError.httpResponseStatus == .notFound else { throw error } - AttachmentViewModel.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [V1] upload attachment...") - progress.addChild(query.progress, withPendingUnitCount: uploadTaskCount) return try await context.apiService.uploadMedia( domain: context.authContext.mastodonAuthenticationBox.domain, @@ -183,8 +178,6 @@ extension AttachmentViewModel { // make sure always count + 1 waitProcessRetryCount += checkUploadTaskCount } - - AttachmentViewModel.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): check attachment process status") let attachmentStatusResponse = try await context.apiService.getMedia( attachmentID: attachmentUploadResponse.value.id, @@ -192,24 +185,18 @@ extension AttachmentViewModel { ).singleOutput() progress.completedUnitCount += checkUploadTaskCount - if let url = attachmentStatusResponse.value.url { - AttachmentViewModel.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): attachment process finish: \(url)") - + if attachmentStatusResponse.value.url != nil { // escape here progress.completedUnitCount = progress.totalUnitCount return .uploadedMastodonAttachment(attachmentStatusResponse.value) } else { - AttachmentViewModel.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): attachment processing. Retry \(waitProcessRetryCount)/\(waitProcessRetryLimit)") try await Task.sleep(nanoseconds: 1_000_000_000 * 3) // 3s } } while waitProcessRetryCount < waitProcessRetryLimit - AttachmentViewModel.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): attachment processing result discard due to exceed retry limit") throw AppError.badRequest } else { - AttachmentViewModel.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): upload attachment success: \(attachmentUploadResponse.value.url ?? "")") - return .uploadedMastodonAttachment(attachmentUploadResponse.value) } } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel.swift index 64441303d..714db2a03 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Attachment/AttachmentViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2021/11/19. // -import os.log import UIKit import Combine import PhotosUI @@ -21,9 +20,6 @@ public protocol AttachmentViewModelDelegate: AnyObject { final public class AttachmentViewModel: NSObject, ObservableObject, Identifiable { - static let logger = Logger(subsystem: "AttachmentViewModel", category: "ViewModel") - let logger = Logger(subsystem: "AttachmentViewModel", category: "ViewModel") - public let id = UUID() var disposeBag = Set() @@ -102,7 +98,6 @@ final public class AttachmentViewModel: NSObject, ObservableObject, Identifiable progress .observe(\.fractionCompleted, options: [.initial, .new]) { [weak self] progress, _ in guard let self = self else { return } - self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): publish progress \(progress.fractionCompleted)") DispatchQueue.main.async { self.fractionCompleted = progress.fractionCompleted } @@ -113,7 +108,6 @@ final public class AttachmentViewModel: NSObject, ObservableObject, Identifiable // progress // .observe(\.isFinished, options: [.initial, .new]) { [weak self] progress, _ in // guard let self = self else { return } - // self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): publish progress \(progress.fractionCompleted)") // DispatchQueue.main.async { // self.objectWillChange.send() // } @@ -182,7 +176,6 @@ final public class AttachmentViewModel: NSObject, ObservableObject, Identifiable } deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) uploadTask?.cancel() diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift index ccb483f35..bfc1760fe 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-5-14. // -import os.log import UIKit import Combine import MastodonCore @@ -103,7 +102,6 @@ extension AutoCompleteViewController { extension AutoCompleteViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: indexPath: %s", ((#file as NSString).lastPathComponent), #line, #function, indexPath.debugDescription) tableView.deselectRow(at: indexPath, animated: true) guard let diffableDataSource = viewModel.diffableDataSource else { return } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewModel+State.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewModel+State.swift index 7f93c4ba7..52f1792cb 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewModel+State.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewModel+State.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-5-17. // -import os.log import Foundation import GameplayKit import MastodonSDK @@ -14,8 +13,6 @@ import MastodonCore extension AutoCompleteViewModel { class State: GKState { - let logger = Logger(subsystem: "AutoCompleteViewModel.State", category: "StateMachine") - let id = UUID() weak var viewModel: AutoCompleteViewModel? @@ -24,22 +21,10 @@ extension AutoCompleteViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(from) -> \(to)") - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) } - - deinit { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [\(self.id.uuidString)] \(String(describing: self))") - } } } @@ -161,7 +146,6 @@ extension AutoCompleteViewModel.State { viewModel.autoCompleteItems.value = items } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): auto-complete fail: \(error.localizedDescription)") await enter(state: Fail.self) } } @@ -204,9 +188,7 @@ extension AutoCompleteViewModel.State { super.didEnter(from: previousState) guard let _ = viewModel, let stateMachine = stateMachine else { return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading 3s later…", ((#file as NSString).lastPathComponent), #line, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: retry loading", ((#file as NSString).lastPathComponent), #line, #function) stateMachine.enter(Loading.self) } } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift index 9187f746e..c373a7a6f 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 22/9/30. // -import os.log import UIKit import SwiftUI import Combine @@ -17,8 +16,6 @@ public final class ComposeContentViewController: UIViewController { static let minAutoCompleteVisibleHeight: CGFloat = 100 - let logger = Logger(subsystem: "ComposeContentViewController", category: "ViewController") - var disposeBag = Set() public var viewModel: ComposeContentViewModel! private(set) lazy var composeContentToolbarViewModel = ComposeContentToolbarView.ViewModel(delegate: self) @@ -233,7 +230,6 @@ extension ComposeContentViewController { switch scrollViewState { case .fold: self.tableView.contentInset.top = -replyToCellFrame.height - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: set contentInset.top: -%s", ((#file as NSString).lastPathComponent), #line, #function, replyToCellFrame.height.description) case .expand: self.tableView.contentInset.top = 0 } @@ -441,7 +437,6 @@ extension ComposeContentViewController { switch viewModel.scrollViewState { case .fold: - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fold") guard velocity.y < 0 else { return } let offsetY = scrollView.contentOffset.y + scrollView.adjustedContentInset.top if offsetY < -44 { @@ -451,7 +446,6 @@ extension ComposeContentViewController { } case .expand: - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): expand") guard velocity.y > 0 else { return } // check if top across let topOffset = (scrollView.contentOffset.y + scrollView.adjustedContentInset.top) - replyToCellFrame.height @@ -511,7 +505,6 @@ extension ComposeContentViewController: UIImagePickerControllerDelegate & UINavi } public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) picker.dismiss(animated: true, completion: nil) } } @@ -594,8 +587,6 @@ extension ComposeContentViewController: AutoCompleteViewControllerDelegate { _ viewController: AutoCompleteViewController, didSelectItem item: AutoCompleteItem ) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): did select item: \(String(describing: item))") - guard let info = viewModel.autoCompleteInfo else { return } guard let metaText = viewModel.contentMetaText else { return } @@ -638,8 +629,6 @@ extension ComposeContentViewController: AutoCompleteViewControllerDelegate { extension ComposeContentViewController: UICollectionViewDelegate { public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: select %s", ((#file as NSString).lastPathComponent), #line, #function, indexPath.debugDescription) - switch collectionView { case customEmojiPickerInputView.collectionView: guard let diffableDataSource = viewModel.customEmojiPickerDiffableDataSource else { return } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+MetaTextDelegate.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+MetaTextDelegate.swift index 8a189739d..9f8330c8e 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+MetaTextDelegate.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+MetaTextDelegate.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022/10/28. // -import os.log import UIKit import MetaTextKit import TwitterMeta diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+UITextViewDelegate.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+UITextViewDelegate.swift index 7813aa63a..53184cdfc 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+UITextViewDelegate.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel+UITextViewDelegate.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022/11/13. // -import os.log import UIKit // MARK: - UITextViewDelegate @@ -36,8 +35,6 @@ extension ComposeContentViewModel: UITextViewDelegate { assertionFailure() return } - let backedString = metaText.backedString - // configure auto completion setupAutoComplete(for: textView) @@ -120,7 +117,6 @@ extension ComposeContentViewModel { self.autoCompleteInfo = nil return } - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: auto complete %s (%s)", ((#file as NSString).lastPathComponent), #line, #function, String(autoCompletion.toHighlightEndString), String(autoCompletion.toCursorString)) // get layout text bounding rect var glyphRange = NSRange() diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift index c3a347aa3..1e669d654 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 22/9/30. // -import os.log import UIKit import Combine import CoreDataStack @@ -27,8 +26,6 @@ public final class ComposeContentViewModel: NSObject, ObservableObject { case editStatus(status: Status, statusSource: Mastodon.Entity.StatusSource) } - let logger = Logger(subsystem: "ComposeContentViewModel", category: "ViewModel") - var disposeBag = Set() // tableViewCell @@ -312,9 +309,6 @@ public final class ComposeContentViewModel: NSObject, ObservableObject { bind() } - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -537,8 +531,6 @@ extension ComposeContentViewModel { extension ComposeContentViewModel { func createNewPollOptionIfCould() { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - guard pollOptions.count < maxPollOptionLimit else { return } let option = PollComposeItem.Option() option.shouldBecomeFirstResponder = true @@ -789,15 +781,13 @@ extension ComposeContentViewModel: AttachmentViewModelDelegate { @MainActor func uploadMediaInQueue() async throws { - for (i, attachmentViewModel) in attachmentViewModels.enumerated() { + for (_, attachmentViewModel) in attachmentViewModels.enumerated() { switch attachmentViewModel.uploadState { case .none: return case .compressing: return case .ready: - let count = self.attachmentViewModels.count - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): upload \(i)/\(count) attachment") try await attachmentViewModel.upload() return case .uploading: diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionTextField.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionTextField.swift index fa409c114..7768ac148 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionTextField.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionTextField.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-27. // -import os.log import UIKit import SwiftUI import Combine @@ -64,8 +63,6 @@ protocol DeleteBackwardResponseTextFieldRelayDelegate: AnyObject { extension PollOptionTextField { public class Coordinator: NSObject { - let logger = Logger(subsystem: "DeleteBackwardResponseTextFieldRepresentable.Coordinator", category: "Coordinator") - var disposeBag = Set() weak var delegate: DeleteBackwardResponseTextFieldRelayDelegate? diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Publisher/MastodonStatusPublisher.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Publisher/MastodonStatusPublisher.swift index 8cb32075b..dfa7d3ef7 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Publisher/MastodonStatusPublisher.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Publisher/MastodonStatusPublisher.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2021-12-1. // -import os.log import Foundation import Combine import CoreData @@ -15,8 +14,6 @@ import MastodonSDK public final class MastodonStatusPublisher: NSObject, ProgressReporting { - let logger = Logger(subsystem: "MastodonStatusPublisher", category: "Publisher") - // Input // author @@ -149,7 +146,6 @@ extension MastodonStatusPublisher: StatusPublisher { // attachmentIDs.append(attachmentID) } } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): upload attachment fail: \(error.localizedDescription)") _state = .failure(error) throw error } @@ -190,7 +186,6 @@ extension MastodonStatusPublisher: StatusPublisher { ) progress.completedUnitCount += publishStatusTaskCount _state = .success - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): status published: \(publishResponse.value.id)") return .post(publishResponse) } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/TableViewCell/ComposeContentTableViewCell.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/TableViewCell/ComposeContentTableViewCell.swift index 90d432825..c81da3be3 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/TableViewCell/ComposeContentTableViewCell.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/TableViewCell/ComposeContentTableViewCell.swift @@ -5,14 +5,11 @@ // Created by MainasuK Cirno on 2021-6-28. // -import os.log import UIKit import UIHostingConfigurationBackport final class ComposeContentTableViewCell: UITableViewCell { - let logger = Logger(subsystem: "ComposeContentTableViewCell", category: "View") - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) _init() diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView.swift index 71f7c9cb5..70430f400 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 22/10/18. // -import os.log import SwiftUI import MastodonAsset import MastodonLocalization diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift index d540985b5..58489a8e2 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 22/9/30. // -import os.log import SwiftUI import MastodonAsset import MastodonCore @@ -14,9 +13,6 @@ import Stripes public struct ComposeContentView: View { - static let logger = Logger(subsystem: "ComposeContentView", category: "View") - var logger: Logger { ComposeContentView.logger } - static let contentViewCoordinateSpace = "ComposeContentView.Content" static var margin: CGFloat = 16 @@ -112,7 +108,6 @@ public struct ComposeContentView: View { Color.clear.preference(key: ViewFramePreferenceKey.self, value: proxy.frame(in: .named(ComposeContentView.contentViewCoordinateSpace))) } .onPreferenceChange(ViewFramePreferenceKey.self) { frame in - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): content textView frame: \(frame.debugDescription)") let rect = frame.standardized viewModel.contentTextViewFrame = CGRect( origin: frame.origin, @@ -132,7 +127,6 @@ public struct ComposeContentView: View { Color.clear.preference(key: ViewFramePreferenceKey.self, value: proxy.frame(in: .local)) } .onPreferenceChange(ViewFramePreferenceKey.self) { frame in - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): content frame: \(frame.debugDescription)") let rect = frame.standardized viewModel.contentCellFrame = CGRect( origin: frame.origin, diff --git a/MastodonSDK/Sources/MastodonUI/View/Container/AudioContainerView.swift b/MastodonSDK/Sources/MastodonUI/View/Container/AudioContainerView.swift index d23759a31..fdce4015a 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Container/AudioContainerView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Container/AudioContainerView.swift @@ -6,7 +6,6 @@ // import CoreDataStack -import os.log import UIKit import MastodonAsset import MastodonLocalization diff --git a/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift b/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift index b28f63942..192101516 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift @@ -6,7 +6,6 @@ // Copyright © 2021 Twidere. All rights reserved. // -import os.log import UIKit import func AVFoundation.AVMakeRect @@ -20,8 +19,6 @@ public final class MediaGridContainerView: UIView { static let sensitiveToggleButtonSize = CGSize(width: 34, height: 34) public static let maxCount = 9 - let logger = Logger(subsystem: "MediaGridContainerView", category: "UI") - public weak var delegate: MediaGridContainerViewDelegate? public private(set) lazy var viewModel: ViewModel = { let viewModel = ViewModel() @@ -79,13 +76,11 @@ extension MediaGridContainerView { extension MediaGridContainerView { @objc private func mediaViewTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { guard let index = _mediaViews.firstIndex(where: { $0.container === sender.view }) else { return } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(index)") let mediaView = _mediaViews[index] delegate?.mediaGridContainerView(self, didTapMediaView: mediaView, at: index) } @objc private func sensitiveToggleButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") delegate?.mediaGridContainerView(self, mediaSensitiveButtonDidPressed: sender) } } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView+ViewModel.swift index 651ae5b13..cd4871414 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView+ViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-5-16. // -import os.log import UIKit import Combine import CoreDataStack @@ -17,8 +16,6 @@ import MastodonLocalization extension FamiliarFollowersDashboardView { public final class ViewModel: ObservableObject { public var disposeBag = Set() - - let logger = Logger(subsystem: "FamiliarFollowersDashboardView", category: "ViewModel") @Published var avatarURLs: [URL?] = [] @Published var names: [String] = [] diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView+ViewModel.swift index a1fdfcbf6..5879eed4f 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView+ViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-21. // -import os.log import UIKit import Combine import Meta @@ -22,8 +21,6 @@ extension NotificationView { public var disposeBag = Set() public var objects = Set() - let logger = Logger(subsystem: "NotificationView", category: "ViewModel") - @Published public var context: AppContext? @Published public var authContext: AuthContext? diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift index 8900b4cb3..394904dc1 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-21. // -import os.log import UIKit import Combine import MetaTextKit @@ -40,8 +39,6 @@ public final class NotificationView: UIView { static let containerLayoutMargin = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16) - let logger = Logger(subsystem: "NotificationView", category: "View") - public weak var delegate: NotificationViewDelegate? var _disposeBag = Set() @@ -434,17 +431,14 @@ extension NotificationView { extension NotificationView { @objc private func avatarButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") delegate?.notificationView(self, authorAvatarButtonDidPressed: avatarButton) } @objc private func acceptFollowRequestButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") delegate?.notificationView(self, acceptFollowRequestButtonDidPressed: sender) } @objc private func rejectFollowRequestButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") delegate?.notificationView(self, rejectFollowRequestButtonDidPressed: sender) } @@ -652,8 +646,6 @@ extension NotificationView: StatusViewDelegate { // MARK: - MastodonMenuDelegate extension NotificationView: MastodonMenuDelegate { public func menuAction(_ action: MastodonMenu.Action) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - delegate?.notificationView(self, menuButton: menuButton, didSelectAction: action) } } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView+ViewModel.swift index 111568e46..2266cc3f2 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView+ViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-14. // -import os.log import UIKit import Combine import Meta @@ -18,7 +17,6 @@ import MastodonCore extension ProfileCardView { public class ViewModel: ObservableObject { - let logger = Logger(subsystem: "ProfileCardView", category: "ViewModel") var disposeBag = Set() public let relationshipViewModel = RelationshipViewModel() diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView.swift index 3da0f7b41..ad8762c71 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-14. // -import os.log import UIKit import Combine import MetaTextKit @@ -18,8 +17,6 @@ public protocol ProfileCardViewDelegate: AnyObject { public final class ProfileCardView: UIView, AXCustomContentProvider { - let logger = Logger(subsystem: "ProfileCardView", category: "View") - static let avatarSize = CGSize(width: 56, height: 56) static let friendshipActionButtonSize = CGSize(width: 108, height: 34) static let contentMargin: CGFloat = 16 @@ -288,13 +285,11 @@ extension ProfileCardView { extension ProfileCardView { @objc private func relationshipActionButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") assert(sender === relationshipActionButton) delegate?.profileCardView(self, relationshipButtonDidPressed: relationshipActionButton) } @objc private func familiarFollowersDashboardViewDidPressed(_ sender: UITapGestureRecognizer) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") assert(sender.view === familiarFollowersDashboardView) delegate?.profileCardView(self, familiarFollowersDashboardViewDidPressed: familiarFollowersDashboardView) } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift index 6d3abd749..4e9c8cbf9 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift @@ -5,7 +5,6 @@ // Created by Jed Fox on 2022-10-31. // -import os.log import UIKit import Combine import Meta @@ -15,7 +14,6 @@ import MastodonCore import MastodonLocalization public class StatusAuthorView: UIStackView { - let logger = Logger(subsystem: "StatusAuthorView", category: "View") private var _disposeBag = Set() // which lifetime same to view scope weak var statusView: StatusView? diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView+ViewModel.swift index fb00ee8a3..b195315aa 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView+ViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-10. // -import os.log import UIKit import Combine import CoreData @@ -25,8 +24,6 @@ extension StatusView { var observations = Set() public var objects = Set() - let logger = Logger(subsystem: "StatusView", category: "ViewModel") - public var context: AppContext? public var authContext: AuthContext? public var originalStatus: Status? @@ -396,9 +393,7 @@ extension StatusView.ViewModel { private func bindMedia(statusView: StatusView) { $mediaViewConfigurations - .sink { [weak self] configurations in - guard let self = self else { return } - + .sink { configurations in statusView.mediaGridContainerView.prepareForReuse() let maxSize = CGSize( diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift index ed1d5ed8c..d669c5d2d 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-1-10. // -import os.log import UIKit import Combine import MetaTextKit @@ -45,8 +44,6 @@ public final class StatusView: UIView { public static let containerLayoutMargin: CGFloat = 16 - let logger = Logger(subsystem: "StatusView", category: "View") - private var _disposeBag = Set() // which lifetime same to view scope public var disposeBag = Set() @@ -394,23 +391,19 @@ extension StatusView { extension StatusView { @objc private func headerDidPressed(_ sender: UITapGestureRecognizer) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") assert(sender.view === headerContainerView) delegate?.statusView(self, headerDidPressed: headerContainerView) } @objc private func pollVoteButtonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") delegate?.statusView(self, pollVoteButtonPressed: pollVoteButton) } @objc private func spoilerOverlayViewTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") delegate?.statusView(self, spoilerOverlayViewDidPressed: spoilerOverlayView) } @objc private func statusCardControlPressed(_ sender: StatusCardControl) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") guard let url = viewModel.card?.url else { return } delegate?.statusView(self, didTapCardWithURL: url) } @@ -723,7 +716,6 @@ extension StatusView: UITextViewDelegate { // MARK: - MetaTextViewDelegate extension StatusView: MetaTextViewDelegate { public func metaTextView(_ metaTextView: MetaTextView, didSelectMeta meta: Meta) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): meta: \(String(describing: meta))") switch metaTextView { case contentMetaText.textView: delegate?.statusView(self, metaText: contentMetaText, didSelectMeta: meta) @@ -748,7 +740,6 @@ extension StatusView: MediaGridContainerViewDelegate { // MARK: - UITableViewDelegate extension StatusView: UITableViewDelegate { public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): select \(indexPath.debugDescription)") switch tableView { case pollTableView: diff --git a/MastodonSDK/Sources/MastodonUI/View/Control/ActionToolbarContainer.swift b/MastodonSDK/Sources/MastodonUI/View/Control/ActionToolbarContainer.swift index 41c5c1b01..1dd2b3b52 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Control/ActionToolbarContainer.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Control/ActionToolbarContainer.swift @@ -5,7 +5,6 @@ // Created by sxiaojian on 2021/2/1. // -import os.log import UIKit import MastodonAsset import MastodonLocalization @@ -19,8 +18,6 @@ public protocol ActionToolbarContainerDelegate: AnyObject { public final class ActionToolbarContainer: UIView { - let logger = Logger(subsystem: "ActionToolbarContainer", category: "Control") - static let replyImage = Asset.Communication.bubbleLeftAndBubbleRight.image.withRenderingMode(.alwaysTemplate) static let reblogImage = Asset.Arrow.repeat.image.withRenderingMode(.alwaysTemplate) static let starImage = Asset.ObjectsAndTools.star.image.withRenderingMode(.alwaysTemplate) @@ -194,8 +191,7 @@ extension ActionToolbarContainer { extension ActionToolbarContainer { @objc private func buttonDidPressed(_ sender: UIButton) { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - + let _action: Action? switch sender { case replyButton: _action = .reply @@ -210,7 +206,6 @@ extension ActionToolbarContainer { return } - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(action.rawValue) button pressed") delegate?.actionToolbarContainer(self, buttonDidPressed: sender, action: action) } diff --git a/MastodonSDK/Sources/MastodonUI/View/Control/ContentWarningOverlayView.swift b/MastodonSDK/Sources/MastodonUI/View/Control/ContentWarningOverlayView.swift index 70be5bbc2..71018898e 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Control/ContentWarningOverlayView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Control/ContentWarningOverlayView.swift @@ -5,14 +5,11 @@ // Created by MainasuK on 2021-12-14. // -import os.log import UIKit import MastodonLocalization public final class ContentWarningOverlayView: UIView { - let logger = Logger(subsystem: "ContentWarningOverlayView", category: "View") - let hintLabel: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 18, weight: .regular) diff --git a/MastodonSDK/Sources/MastodonUI/View/Control/ProfileStatusDashboardView.swift b/MastodonSDK/Sources/MastodonUI/View/Control/ProfileStatusDashboardView.swift index 3be447292..0fb25a239 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Control/ProfileStatusDashboardView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Control/ProfileStatusDashboardView.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-30. // -import os.log import UIKit import MastodonAsset import MastodonLocalization @@ -79,7 +78,6 @@ extension ProfileStatusDashboardView { extension ProfileStatusDashboardView { @objc private func tapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { - os_log(.debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) guard let sourceView = sender.view as? ProfileStatusDashboardMeterView else { assertionFailure() return diff --git a/MastodonSDK/Sources/MastodonUI/View/Control/StripProgressView.swift b/MastodonSDK/Sources/MastodonUI/View/Control/StripProgressView.swift index 8d429594f..3bcfbe462 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Control/StripProgressView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Control/StripProgressView.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-3-3. // -import os.log import UIKit import Combine @@ -34,8 +33,6 @@ public final class StripProgressLayer: CALayer { return presentation()?.progress ?? self.progress }() - // os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: progress: %.2f", ((#file as NSString).lastPathComponent), #line, #function, progress) - UIGraphicsBeginImageContextWithOptions(bounds.size, false, 0) guard let context = UIGraphicsGetCurrentContext() else { assertionFailure() diff --git a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell+Configuration.swift b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell+Configuration.swift index 1274b7960..d4767048a 100644 --- a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell+Configuration.swift +++ b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell+Configuration.swift @@ -21,7 +21,6 @@ extension ProfileCardTableViewCell { assert(layoutMarginsGuide.layoutFrame.width > .zero) shadowBackgroundContainer.frame.size.width = layoutMarginsGuide.layoutFrame.width profileCardView.setupLayoutFrame(layoutMarginsGuide.layoutFrame) - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): did layout for new cell") } profileCardView.configure(user: user) diff --git a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell.swift b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell.swift index a14028ea2..3b3227e23 100644 --- a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell.swift +++ b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022-4-14. // -import os.log import UIKit import Combine @@ -16,8 +15,6 @@ public protocol ProfileCardTableViewCellDelegate: AnyObject { public final class ProfileCardTableViewCell: UITableViewCell { - let logger = Logger(subsystem: "ProfileCardTableViewCell", category: "Cell") - public weak var delegate: ProfileCardTableViewCellDelegate? public var disposeBag = Set() diff --git a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineMiddleLoaderTableViewCell.swift b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineMiddleLoaderTableViewCell.swift index 7cb5f2b44..7b928c97a 100644 --- a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineMiddleLoaderTableViewCell.swift +++ b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineMiddleLoaderTableViewCell.swift @@ -7,7 +7,6 @@ import Combine import CoreData -import os.log import UIKit public protocol TimelineMiddleLoaderTableViewCellDelegate: AnyObject { @@ -60,7 +59,6 @@ public final class TimelineMiddleLoaderTableViewCell: TimelineLoaderTableViewCel extension TimelineMiddleLoaderTableViewCell { @objc private func loadMoreButtonDidPressed(_ sender: UIButton) { - os_log("%{public}s[%{public}ld], %{public}s", (#file as NSString).lastPathComponent, #line, #function) delegate?.timelineMiddleLoaderTableViewCell(self, loadMoreButtonDidPressed: sender) } } diff --git a/MastodonSDK/Sources/MastodonUI/View/Utility/ViewLayoutFrame.swift b/MastodonSDK/Sources/MastodonUI/View/Utility/ViewLayoutFrame.swift index e97453fdb..c879489bd 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Utility/ViewLayoutFrame.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Utility/ViewLayoutFrame.swift @@ -5,13 +5,10 @@ // Created by MainasuK on 2022-8-17. // -import os.log import UIKit import CoreGraphics public struct ViewLayoutFrame { - let logger = Logger(subsystem: "ViewLayoutFrame", category: "ViewLayoutFrame") - public var layoutFrame: CGRect public var safeAreaLayoutFrame: CGRect public var readableContentLayoutFrame: CGRect diff --git a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+AccountTests.swift b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+AccountTests.swift index b113672ec..6ea98595f 100644 --- a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+AccountTests.swift +++ b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+AccountTests.swift @@ -5,7 +5,6 @@ // Created by jk234ert on 2/9/21. // -import os.log import XCTest import Combine import UIKit diff --git a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+AppTests.swift b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+AppTests.swift index 5638a9754..1a7f339eb 100644 --- a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+AppTests.swift +++ b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+AppTests.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021/1/29. // -import os.log import XCTest import Combine @testable import MastodonSDK @@ -37,8 +36,6 @@ extension MastodonSDKTests { XCTAssertEqual(response.value.name, "XCTest") XCTAssertEqual(response.value.website, nil) XCTAssertEqual(response.value.redirectURI, "urn:ietf:wg:oauth:2.0:oob") - os_log("%{public}s[%{public}ld], %{public}s: (%s) clientID %s", ((#file as NSString).lastPathComponent), #line, #function, domain, response.value.clientID ?? "nil") - os_log("%{public}s[%{public}ld], %{public}s: (%s) clientSecret %s", ((#file as NSString).lastPathComponent), #line, #function, domain, response.value.clientSecret ?? "nil") theExpectation.fulfill() } .store(in: &disposeBag) diff --git a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+Instance.swift b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+Instance.swift index ee02cf073..a89d50a42 100644 --- a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+Instance.swift +++ b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+Instance.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-2-5. // -import os.log import XCTest import Combine @testable import MastodonSDK diff --git a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OAuthTests.swift b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OAuthTests.swift index c1f09eb99..9a04aea04 100644 --- a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OAuthTests.swift +++ b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OAuthTests.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021/1/29. // -import os.log import XCTest import Combine @testable import MastodonSDK @@ -19,7 +18,6 @@ extension MastodonSDKTests { func _testOAuthAuthorize(domain: String) throws { let query = Mastodon.API.OAuth.AuthorizeQuery(clientID: "StubClientID", redirectURI: "mastodon://joinmastodon.org/oauth") let authorizeURL = Mastodon.API.OAuth.authorizeURL(domain: domain, query: query) - os_log("%{public}s[%{public}ld], %{public}s: (%s) authorizeURL %s", ((#file as NSString).lastPathComponent), #line, #function, domain, authorizeURL.absoluteString) XCTAssertEqual( authorizeURL.absoluteString, "\(URL.httpScheme(domain: domain))://\(domain)/oauth/authorize?response_type=code&client_id=StubClientID&redirect_uri=mastodon://joinmastodon.org/oauth&scope=read%20write%20follow%20push" diff --git a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OnboardingTests.swift b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OnboardingTests.swift index 0590888f6..fbe03b86b 100644 --- a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OnboardingTests.swift +++ b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OnboardingTests.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-2-18. // -import os.log import XCTest import Combine @testable import MastodonSDK @@ -13,8 +12,8 @@ import Combine extension MastodonSDKTests { func testServers() throws { - try _testServers(query: Mastodon.API.Onboarding.ServersQuery(language: nil, category: nil)) - try _testServers(query: Mastodon.API.Onboarding.ServersQuery(language: "en", category: "tech")) + try _testServers(query: Mastodon.API.Onboarding.ServersQuery(language: nil, category: nil, registrations: nil)) + try _testServers(query: Mastodon.API.Onboarding.ServersQuery(language: "en", category: "tech", registrations: nil)) } func _testServers(query: Mastodon.API.Onboarding.ServersQuery) throws { diff --git a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+TimelineTests.swift b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+TimelineTests.swift index 68e5bb669..973de3480 100644 --- a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+TimelineTests.swift +++ b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+TimelineTests.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021/2/3. // -import os.log import XCTest import Combine @testable import MastodonSDK diff --git a/NotificationService/NotificationService+Decrypt.swift b/NotificationService/NotificationService+Decrypt.swift index 858e7c2c5..e1abfea65 100644 --- a/NotificationService/NotificationService+Decrypt.swift +++ b/NotificationService/NotificationService+Decrypt.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-4-25. // -import os.log import Foundation import CryptoKit @@ -13,7 +12,6 @@ extension NotificationService { static func decrypt(payload: Data, salt: Data, auth: Data, privateKey: P256.KeyAgreement.PrivateKey, publicKey: P256.KeyAgreement.PublicKey) -> Data? { guard let sharedSecret = try? privateKey.sharedSecretFromKeyAgreement(with: publicKey) else { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: failed to craete shared secret", ((#file as NSString).lastPathComponent), #line, #function) return nil } @@ -28,7 +26,6 @@ extension NotificationService { let nonceData = nonce.withUnsafeBytes(Array.init) guard let sealedBox = try? AES.GCM.SealedBox(combined: nonceData + payload) else { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: failed to create sealedBox", ((#file as NSString).lastPathComponent), #line, #function) return nil } @@ -36,10 +33,8 @@ extension NotificationService { do { _plaintext = try AES.GCM.open(sealedBox, using: key) } catch { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: sealedBox open fail %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription) } guard let plaintext = _plaintext else { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: failed to open sealedBox", ((#file as NSString).lastPathComponent), #line, #function) return nil } diff --git a/NotificationService/NotificationService.swift b/NotificationService/NotificationService.swift index d38884aff..a17cbfd2a 100644 --- a/NotificationService/NotificationService.swift +++ b/NotificationService/NotificationService.swift @@ -6,7 +6,6 @@ // import UserNotifications -import CommonOSLog import CryptoKit import AlamofireImage import MastodonCore @@ -22,13 +21,11 @@ class NotificationService: UNNotificationServiceExtension { if let bestAttemptContent = bestAttemptContent { // Modify the notification content here... - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) let privateKey = AppSecret.default.notificationPrivateKey let auth = AppSecret.default.notificationAuth guard let encodedPayload = bestAttemptContent.userInfo["p"] as? String else { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: invalid payload", ((#file as NSString).lastPathComponent), #line, #function) contentHandler(bestAttemptContent) return } @@ -36,13 +33,11 @@ class NotificationService: UNNotificationServiceExtension { guard let encodedPublicKey = bestAttemptContent.userInfo["k"] as? String, let publicKey = NotificationService.publicKey(encodedPublicKey: encodedPublicKey) else { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: invalid public key", ((#file as NSString).lastPathComponent), #line, #function) contentHandler(bestAttemptContent) return } guard let encodedSalt = bestAttemptContent.userInfo["s"] as? String else { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: invalid salt", ((#file as NSString).lastPathComponent), #line, #function) contentHandler(bestAttemptContent) return } @@ -75,10 +70,9 @@ class NotificationService: UNNotificationServiceExtension { ImageDownloader.default.download(URLRequest(url: url), completion: { [weak self] response in guard let _ = self else { return } switch response.result { - case .failure(let error): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: download image %s fail: %s", ((#file as NSString).lastPathComponent), #line, #function, url.debugDescription, error.localizedDescription) + case .failure(_): + break case .success(let image): - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: download image %s success", ((#file as NSString).lastPathComponent), #line, #function, url.debugDescription) try? image.pngData()?.write(to: fileURL) if let attachment = try? UNNotificationAttachment(identifier: filename, url: fileURL, options: nil) { bestAttemptContent.attachments = [attachment] diff --git a/Podfile b/Podfile index b86a50868..9341259cd 100644 --- a/Podfile +++ b/Podfile @@ -18,7 +18,6 @@ target 'Mastodon' do pod 'Sourcery', '~> 1.9' # DEBUG - pod 'FLEX', '~> 5.22.10', :configurations => ['Debug', "Release Snapshot"] target 'MastodonTests' do inherit! :search_paths diff --git a/Podfile.lock b/Podfile.lock index b83291363..d2d050297 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,4 @@ PODS: - - FLEX (5.22.10) - Kanna (5.2.7) - Sourcery (1.9.0): - Sourcery/CLI-Only (= 1.9.0) @@ -8,7 +7,6 @@ PODS: - XLPagerTabStrip (9.0.0) DEPENDENCIES: - - FLEX (~> 5.22.10) - Kanna (~> 5.2.2) - Sourcery (~> 1.9) - SwiftGen (~> 6.6.2) @@ -16,19 +14,17 @@ DEPENDENCIES: SPEC REPOS: trunk: - - FLEX - Kanna - Sourcery - SwiftGen - XLPagerTabStrip SPEC CHECKSUMS: - FLEX: f21ee4f498eed3f8a1eded66b21939fd3b7a22ce Kanna: 01cfbddc127f5ff0963692f285fcbc8a9d62d234 Sourcery: d7c59d100e55bf59123c8ae7d65a24cf30748979 SwiftGen: 1366a7f71aeef49954ca5a63ba4bef6b0f24138c XLPagerTabStrip: 61c57fd61f611ee5f01ff1495ad6fbee8bf496c5 -PODFILE CHECKSUM: 219ef7456c1c3111c3f61653632501ce09918bf0 +PODFILE CHECKSUM: 698a840245d400e5a1c93345481965cc16067dc0 COCOAPODS: 1.12.1 diff --git a/ShareActionExtension/Scene/ShareViewController.swift b/ShareActionExtension/Scene/ShareViewController.swift index 6b2ed1323..046ce5385 100644 --- a/ShareActionExtension/Scene/ShareViewController.swift +++ b/ShareActionExtension/Scene/ShareViewController.swift @@ -5,7 +5,6 @@ // Created by MainasuK on 2022/11/13. // -import os.log import UIKit import Combine import CoreDataStack @@ -17,8 +16,6 @@ import UniformTypeIdentifiers final class ShareViewController: UIViewController { - let logger = Logger(subsystem: "ShareViewController", category: "ViewController") - var disposeBag = Set() let context = AppContext.shared @@ -65,9 +62,6 @@ final class ShareViewController: UIViewController { return label }() - deinit { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } } @@ -120,7 +114,6 @@ extension ShareViewController { await load(inputItems: inputItems) } // end Task } catch { - logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): error: \(error.localizedDescription)") } viewModel.$isPublishing @@ -141,15 +134,10 @@ extension ShareViewController { extension ShareViewController { @objc private func cancelBarButtonItemPressed(_ sender: UIBarButtonItem) { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - extensionContext?.cancelRequest(withError: NSError(domain: "org.joinmastodon.app.ShareActionExtension", code: -1)) } @objc private func publishBarButtonItemPressed(_ sender: UIBarButtonItem) { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - - Task { @MainActor in viewModel.isPublishing = true do { @@ -224,14 +212,8 @@ extension ShareViewController: UIAdaptivePresentationControllerDelegate { } func presentationControllerDidAttemptToDismiss(_ presentationController: UIPresentationController) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) showDismissConfirmAlertController() } - - func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { - os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - } - } extension ShareViewController { diff --git a/ShareActionExtension/Scene/ShareViewModel.swift b/ShareActionExtension/Scene/ShareViewModel.swift index ef8e200a6..d2c67373b 100644 --- a/ShareActionExtension/Scene/ShareViewModel.swift +++ b/ShareActionExtension/Scene/ShareViewModel.swift @@ -5,7 +5,6 @@ // Created by MainasuK Cirno on 2021-7-16. // -import os.log import Foundation import Combine import CoreData @@ -20,8 +19,6 @@ import MastodonCore final class ShareViewModel { - let logger = Logger(subsystem: "ComposeViewModel", category: "ViewModel") - var disposeBag = Set() // input diff --git a/WidgetExtension/Variants/FollowersCount/FollowersCountHistory.swift b/WidgetExtension/Variants/FollowersCount/FollowersCountHistory.swift index cc38ec180..7a9041578 100644 --- a/WidgetExtension/Variants/FollowersCount/FollowersCountHistory.swift +++ b/WidgetExtension/Variants/FollowersCount/FollowersCountHistory.swift @@ -93,7 +93,6 @@ class FollowersCountHistory { let history = followersHistorySorted(for: account) let relevantDays = elapsedFollowersCountDateStrings() let today = relevantDays.last! - let yesterday = relevantDays[relevantDays.count - 2] let followersToday = history.first(where: { $0.dstring == today })?.count ?? account.followersCount let followersYesterday = history[safe: history.count-2]?.count ?? account.followersCount