Skip to content

Commit

Permalink
Replace Prints with os.log
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Sep 12, 2022
1 parent bbf6b9f commit d813f3e
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 13 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

Bouncer.xcodeproj/project.xcworkspace/xcuserdata/afterxleep.xcuserdatad/UserInterfaceState.xcuserstate
/.DS_Store
6 changes: 6 additions & 0 deletions Bouncer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
D67F582E24E4496300165365 /* AppSettingsDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D67F582C24E4496300165365 /* AppSettingsDefaults.swift */; };
D67F582F24E4496300165365 /* AppSettingsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = D67F582D24E4496300165365 /* AppSettingsStore.swift */; };
D6B2CC8D24EF16C6004F72C4 /* wordlist.filter in Resources */ = {isa = PBXBuildFile; fileRef = D6B2CC8C24EF16C6004F72C4 /* wordlist.filter */; };
D6BE8B8728CFE0C3004E7274 /* OSLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BE8B8628CFE0C3004E7274 /* OSLog.swift */; };
D6BE8B8828CFE230004E7274 /* OSLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BE8B8628CFE0C3004E7274 /* OSLog.swift */; };
D6C90BF224CAAF7B00426B31 /* AppState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C90BF124CAAF7B00426B31 /* AppState.swift */; };
D6C90BF424CAB26700426B31 /* AppStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C90BF324CAB26700426B31 /* AppStore.swift */; };
D6C90BF624CB36AE00426B31 /* FilterRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C90BF524CB36AD00426B31 /* FilterRowView.swift */; };
Expand Down Expand Up @@ -142,6 +144,7 @@
D67F582D24E4496300165365 /* AppSettingsStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppSettingsStore.swift; sourceTree = "<group>"; };
D6B2CC8C24EF16C6004F72C4 /* wordlist.filter */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = wordlist.filter; sourceTree = "<group>"; };
D6BAC9EE26D7A156007ACCBE /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
D6BE8B8628CFE0C3004E7274 /* OSLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSLog.swift; sourceTree = "<group>"; };
D6C90BF124CAAF7B00426B31 /* AppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppState.swift; sourceTree = "<group>"; };
D6C90BF324CAB26700426B31 /* AppStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStore.swift; sourceTree = "<group>"; };
D6C90BF524CB36AD00426B31 /* FilterRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterRowView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -401,6 +404,7 @@
children = (
D664B24724AA998700EB826D /* UIImage+Gradient.swift */,
09491AEE261D30A400CF8073 /* String+Empty.swift */,
D6BE8B8628CFE0C3004E7274 /* OSLog.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -661,6 +665,7 @@
files = (
D6233A8324A653F200B37A6A /* FilterStoreFile.swift in Sources */,
D6EA9A8524AD2319000135E7 /* FilterStore.swift in Sources */,
D6BE8B8828CFE230004E7274 /* OSLog.swift in Sources */,
D60A19C824A6A2C80002E8BD /* SMSMessage.swift in Sources */,
D6233A8124A6538D00B37A6A /* SMSOfflineFilter.swift in Sources */,
D6233A7224A650B700B37A6A /* MessageFilterExtension.swift in Sources */,
Expand All @@ -675,6 +680,7 @@
D6233A7F24A651A200B37A6A /* SMSOfflineFilter.swift in Sources */,
D6529F9F24A413A6009AE3FF /* TutorialView.swift in Sources */,
D60A19C724A69F1F0002E8BD /* SMSMessage.swift in Sources */,
D6BE8B8728CFE0C3004E7274 /* OSLog.swift in Sources */,
D61497E924E4430E00AF997E /* FilterAction.swift in Sources */,
D6CC124D24E4563F00388160 /* SettingsAction.swift in Sources */,
D664B24824AA998700EB826D /* UIImage+Gradient.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
filePath = "Bouncer/Models/FilterStore/FilterStoreFile.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "99"
endingLineNumber = "99"
startingLineNumber = "97"
endingLineNumber = "97"
landmarkName = "add(filter:)"
landmarkType = "7">
</BreakpointContent>
Expand Down
19 changes: 19 additions & 0 deletions Bouncer/Extensions/OSLog.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// OSLog.swift
// Bouncer
//
// Created by Daniel on 12/09/22.
//

import Foundation
import os.log

extension OSLog {
private static var subsystem = Bundle.main.bundleIdentifier!

/// Logs message filter related messages
static let messageFilterLog = OSLog(subsystem: subsystem, category: "messageFilter")

/// Logs Erross
static let errorLog = OSLog(subsystem: subsystem, category: "errorLog")
}
2 changes: 1 addition & 1 deletion Bouncer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>169</string>
<string>173</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
Expand Down
6 changes: 2 additions & 4 deletions Bouncer/Models/FilterStore/FilterStoreFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import Foundation
import Combine
import os.log

private typealias DiskWriteError = String

Expand Down Expand Up @@ -41,10 +42,7 @@ final class FilterStoreFile: FilterStore {
return nil
} catch {
let errorMessage = error.localizedDescription
#if DEBUG
print(errorMessage)
#endif

os_log("Error: %s.", type: .error, errorMessage)
return errorMessage
}
}
Expand Down
Binary file modified BouncerTests/Models/AppSettingsDefaultsTests.swift.plist
Binary file not shown.
2 changes: 1 addition & 1 deletion smsfilter/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>169</string>
<string>173</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
10 changes: 5 additions & 5 deletions smsfilter/MessageFilterExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ final class MessageFilterExtension: ILMessageFilterExtension {
var cancellables = [AnyCancellable]()

override init() {
print("FILTEREXTENSION - Message filtering Started.")
super.init()
os_log("FILTEREXTENSION - Message filtering Started.", log: OSLog.messageFilterLog, type: .info)
super.init()
fetchFilters()
}

deinit {
print("FILTEREXTENSION - Message filtering complete")
os_log("FILTEREXTENSION - Message filtering complete.", log: OSLog.messageFilterLog, type: .info)
}

func fetchFilters() {
filterStore.fetch()
.receive(on: RunLoop.main)
.sink(receiveCompletion: {_ in
}, receiveValue: { [weak self] result in
print("FILTEREXTENSION - Filter list loaded")
os_log("FILTEREXTENSION - Filter list loaded", log: OSLog.messageFilterLog, type: .info)
self?.filters = result
})
.store(in: &self.cancellables)
Expand All @@ -50,7 +50,7 @@ extension MessageFilterExtension: ILMessageFilterQueryHandling {
}
let filter = SMSOfflineFilter(filterList: filters)
response.action = filter.filterMessage(message: SMSMessage(sender: sender, text: messageBody))
print("FILTEREXTENSION - Filtering done")
os_log("FILTEREXTENSION - Filtering done", log: OSLog.messageFilterLog, type: .info)
completion(response)
}
}

0 comments on commit d813f3e

Please sign in to comment.