Skip to content

Commit

Permalink
feat(ios): add useLog config #1431
Browse files Browse the repository at this point in the history
  • Loading branch information
stewones committed Jun 6, 2019
1 parent e964068 commit c01c211
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ios/Capacitor/Capacitor/CAPBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,10 @@ enum BridgeError: Error {
public func toJs(result: JSResult, save: Bool) {
do {
let resultJson = try result.toJson()
print("⚡️ TO JS", resultJson.prefix(256))

if (CAPConfig.useLog() as? Bool != false) {
print("⚡️ TO JS", resultJson.prefix(256))
}

DispatchQueue.main.async {
self.getWebView()?.evaluateJavaScript("""
Expand Down
8 changes: 6 additions & 2 deletions ios/Capacitor/Capacitor/CAPBridgeDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ extension CAPBridgeDelegate {
let options = dict["options"] as? [String:Any] ?? [:]

if pluginId != "Console" {
print("⚡️ To Native -> ", pluginId, method, callbackId)
if (CAPConfig.useLog() as? Bool != false) {
print("⚡️ To Native -> ", pluginId, method, callbackId)
}
}

bridge.handleJSCall(call: JSCall(options: options, pluginId: pluginId, method: method, callbackId: callbackId))
Expand All @@ -35,7 +37,9 @@ extension CAPBridgeDelegate {
let args = dict["actionArgs"] as? Array ?? []
let options = ["options":args]

print("To Native Cordova -> ", pluginId, method, callbackId, options)
if (CAPConfig.useLog() as? Bool != false) {
print("To Native Cordova -> ", pluginId, method, callbackId, options)
}

bridge.handleCordovaJSCall(call: JSCall(options: options, pluginId: pluginId, method: method, callbackId: callbackId))
}
Expand Down
8 changes: 8 additions & 0 deletions ios/Capacitor/Capacitor/CAPConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,12 @@
}
return value as? String
}

@objc public static func useLog() -> Any? {
let shouldUseLog = CAPConfig.getValue("useLog") as? Bool
if (shouldUseLog != false) {
return true
}
return false;
}
}

0 comments on commit c01c211

Please sign in to comment.