Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10669384
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
View Options
diff --git a/Shared/Logging/Logging.swift b/Shared/Logging/Logging.swift
index b1e88a0..64d7f9c 100644
--- a/Shared/Logging/Logging.swift
+++ b/Shared/Logging/Logging.swift
@@ -1,40 +1,50 @@
//
// Logging.swift
// WriteFreely-MultiPlatform
//
// Created by Angelo Stavrow on 2022-06-25.
//
import Foundation
import os
+import OSLog
+
+protocol LogWriter {
+ func log(_ message: String, withSensitiveInfo privateInfo: String?, level: OSLogType)
+ func logCrashAndSetFlag(error: Error)
+}
final class Logging {
private let logger: Logger
private let subsystem = Bundle.main.bundleIdentifier!
- init(for category: String) {
+ init(for category: String = "") {
self.logger = Logger(subsystem: subsystem, category: category)
}
+}
+
+extension Logging: LogWriter {
+
func log(
_ message: String,
withSensitiveInfo privateInfo: String? = nil,
level: OSLogType = .default
) {
if let privateInfo = privateInfo {
logger.log(level: level, "\(message): \(privateInfo, privacy: .sensitive)")
} else {
logger.log(level: level, "\(message)")
}
}
func logCrashAndSetFlag(error: Error) {
let errorDescription = error.localizedDescription
UserDefaults.shared.set(true, forKey: WFDefaults.didHaveFatalError)
UserDefaults.shared.set(errorDescription, forKey: WFDefaults.fatalErrorDescription)
- logger.critical("\(errorDescription)")
+ logger.log(level: .error, "\(errorDescription)")
fatalError(errorDescription)
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, May 16, 5:33 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3239981
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment