Files
breez-sdk-liquid/lib/bindings/langs/swift/Sources/BreezSDKLiquid/ServiceLogger.swift
Ross Savage b493f3dc03 Swift notification plugin (#436)
* Add Swift notification plugin

* Hash the metadata

* Validate min sendable amount

* Remove initializer as base class, UNNotificationServiceExtension, has no default initializer

* Set the PaymentMethod

* Handle PaymentDetails in SwapUpdated

* Improve payment text
2024-08-30 09:20:13 +02:00

41 lines
1.2 KiB
Swift

import Foundation
import os.log
#if DEBUG && true
fileprivate var logger = OSLog(
subsystem: Bundle.main.bundleIdentifier!,
category: "ServiceLogger"
)
#else
fileprivate var logger = OSLog.disabled
#endif
open class ServiceLogger {
var logStream: Logger?
init(logStream: Logger?) {
self.logStream = logStream
}
public func log(tag: String, line: String, level: String) {
if let logger = logStream {
logger.log(l: LogEntry(line: line, level: level))
} else {
switch(level) {
case "ERROR":
os_log("[%{public}@] %{public}@", log: logger, type: .error, tag, line)
break
case "INFO", "WARN":
os_log("[%{public}@] %{public}@", log: logger, type: .info, tag, line)
break
case "TRACE":
os_log("[%{public}@] %{public}@", log: logger, type: .debug, tag, line)
break
default:
os_log("[%{public}@] %{public}@", log: logger, type: .default, tag, line)
return
}
}
}
}