Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10493987
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 64d7f9c..27f7980 100644
--- a/Shared/Logging/Logging.swift
+++ b/Shared/Logging/Logging.swift
@@ -1,50 +1,67 @@
//
// 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)
}
+protocol LogReader {
+ func fetchLogs() -> [String]
+}
+
final class Logging {
private let logger: Logger
private let subsystem = Bundle.main.bundleIdentifier!
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.log(level: .error, "\(errorDescription)")
fatalError(errorDescription)
}
}
+
+extension Logging: LogReader {
+
+ func fetchLogs() -> [String] {
+ return [
+ "This is line 1",
+ "This is line 2",
+ "This is line 3",
+ "This is line 4"
+ ]
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Mar 6, 3:10 AM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3168174
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment