Skip to content

Commit

Permalink
FFM-8360 - iOS SDK - Remove NSLog calls and use Logger instead (#34)
Browse files Browse the repository at this point in the history
What
Avoid calling NSLog directly from source

Why
Better to call Logger instead so that logs can be filtered depending on their level

Testing
Manual + see FFM-8042
  • Loading branch information
andybharness authored Jul 3, 2023
1 parent dbd643c commit af742fa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You can also add the `ff-ios-client-sdk` dependency locally by dragging the SDK

```Swift
dependencies: [
.package(url: "https://github.com/harness/ff-ios-client-sdk.git", .upToNextMinor(from: "1.0.4"))
.package(url: "https://github.com/harness/ff-ios-client-sdk.git", .upToNextMinor(from: "1.1.0"))
]
```
 
Expand Down
6 changes: 3 additions & 3 deletions Sources/ff-ios-client-sdk/API/OpenAPIs/APIs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
open class OpenAPIClientAPI {

public static var configPath = CfConstants.Server.configUrl // "https://config.ff.harness.io/api/1.0"
public static var streamPath = CfConstants.Server.streamUrl // "https://config.ff.harness.io/api/1.0"
public static var streamPath = CfConstants.Server.streamUrl // "https://config.ff.harness.io/api/1.0"
public static var eventPath = CfConstants.Server.eventUrl // "https://events.ff.harness.io/api/1.0"

public static var credential: URLCredential?
Expand All @@ -19,6 +19,7 @@ open class OpenAPIClientAPI {
}

open class RequestBuilder<T> {
private let log = SdkLog.get("io.harness.ff.sdk.ios.RequestBuilder")
var credential: URLCredential?
var headers: [String:String]
public let parameters: [String:Any]?
Expand Down Expand Up @@ -51,8 +52,7 @@ open class RequestBuilder<T> {
addHeaders(additionalHeaders)

for (header, value) in self.headers {

NSLog("Header: \(header) -> \(value)")
log.debug("Header: \(header) -> \(value)")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import Foundation

open class DefaultAPI {

private static let log = SdkLog.get("io.harness.ff.sdk.ios.DefaultAPI")

/**
Authenticate with the admin server.

Expand Down Expand Up @@ -157,7 +160,7 @@ open class DefaultAPI {
method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false
)

NSLog("API getEvaluations: \(req.URLString)")
DefaultAPI.log.debug("API getEvaluations: \(req.URLString)")
return req
}

Expand Down Expand Up @@ -199,7 +202,7 @@ open class DefaultAPI {
method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false
)

NSLog("API getEvaluationByIdentifier: \(req.URLString)")
DefaultAPI.log.debug("API getEvaluationByIdentifier: \(req.URLString)")
return req
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Foundation

open class MetricsAPI {


private static let log = SdkLog.get("io.harness.ff.sdk.ios.MetricsAPI")

/**
Post metrics data.

Expand Down Expand Up @@ -76,7 +78,7 @@ open class MetricsAPI {
isBody: true
)

NSLog("API postMetrics: URL=\(req.URLString), HEADERS=\(req.headers), METHOD=\(req.method)")
MetricsAPI.log.debug("API postMetrics: URL=\(req.URLString), HEADERS=\(req.headers), METHOD=\(req.method)")
return req
}
}
6 changes: 4 additions & 2 deletions Sources/ff-ios-client-sdk/CfClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -790,12 +790,14 @@ public class CfClient {
self.setupFlowFor(.onlinePolling)
guard error == nil else {

NSLog("Api, eventSourceManager.onComplete: \(error!)")
let errStr = error?.localizedDescription ?? ""
CfClient.log.warn("Api, eventSourceManager.onComplete: error=\(errStr)")
onEvent(EventType.onComplete, error)
return
}

NSLog("Api, eventSourceManager.onComplete: \(statusCode!)")
let statusStr = statusCode ?? -1;
CfClient.log.info("Api, eventSourceManager.onComplete: status=\(statusStr)")
onEvent(EventType.onComplete, nil)
}

Expand Down

0 comments on commit af742fa

Please sign in to comment.