Skip to content

Commit ef528da

Browse files
committed
Add more logs
1 parent 135d0bc commit ef528da

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ORLib/ConsoleProviders/ESPProvision/ORConfigChannel.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import Foundation
2121
import ESPProvision
22+
import OSLog
2223

2324
struct DeviceInfo {
2425
let deviceId: String
@@ -33,6 +34,11 @@ enum BackendConnectionStatus {
3334
}
3435

3536
struct ORConfigChannel {
37+
private static let logger = Logger(
38+
subsystem: Bundle.main.bundleIdentifier!,
39+
category: String(describing: ORConfigChannel.self)
40+
)
41+
3642
let device: ORESPDevice
3743

3844
var messageId = 0
@@ -103,12 +109,15 @@ struct ORConfigChannel {
103109
var request = Request()
104110
request.body = .exitProvisioning(Request.ExitProvisioning())
105111

112+
Self.logger.info("Sending exitProvisioning request")
106113
_ = try await sendRequest(request)
114+
Self.logger.info("ExitProvisioning request sent")
107115
}
108116

109117
private mutating func sendRequest(_ request: Request) async throws -> Response {
110118
var request = request
111119
request.id = String(messageId)
120+
Self.logger.info("Send request with messageId: \(request.id)")
112121
messageId += 1
113122

114123
do {
@@ -118,9 +127,10 @@ struct ORConfigChannel {
118127
}
119128
return try await withCheckedThrowingContinuation { continuation in
120129
device.sendData(path: "or-cfg", data: requestData) { responseData, error in
130+
Self.logger.info("Received a response")
121131
if let error {
122-
// TODO:
123-
print("Error: \(error.localizedDescription)")
132+
// TODO: anything better to do with error ?
133+
Self.logger.error("Error sending request: \(error.localizedDescription)")
124134
continuation.resume(throwing: ORConfigChannelError.genericError)
125135
} else if let responseData {
126136
do {

0 commit comments

Comments
 (0)