Skip to content

Commit 899597f

Browse files
committed
Use os.Logger commands for printing
1 parent f62b407 commit 899597f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

templates/BindingsTemplate.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import Foundation
9+
import os
910

1011
public typealias LDKTransactionOutputs = LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ
1112
public typealias TransactionOutputs = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ
@@ -63,6 +64,7 @@ open class NativeTypeWrapper: Hashable {
6364

6465
public class Bindings {
6566

67+
internal static let logger = os.Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ldk")
6668
internal static var minimumPrintSeverity: PrintSeverity = .WARNING
6769

6870
public enum PrintSeverity: UInt {
@@ -73,7 +75,15 @@ public class Bindings {
7375

7476
internal class func print(_ string: String, severity: PrintSeverity = .DEBUG) {
7577
if severity.rawValue >= Self.minimumPrintSeverity.rawValue {
76-
Swift.print(string)
78+
if severity == Self.PrintSeverity.DEBUG {
79+
logger.debug("\(string)")
80+
}else if severity == Self.PrintSeverity.WARNING {
81+
logger.warning("\(string)")
82+
}else if severity == Self.PrintSeverity.ERROR {
83+
logger.error("\(string)")
84+
}else {
85+
logger.log("\(string)")
86+
}
7787
}
7888
}
7989

0 commit comments

Comments
 (0)