You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2013/02/25 14:41:01 UTC

[43/50] ios commit: Add a define that turns on logging of exec() bridge

Add a define that turns on logging of exec() bridge


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/0b408219
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/0b408219
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/0b408219

Branch: refs/heads/multipart_plugin_result
Commit: 0b408219000f1ac66f01a7ee17dcde0578991a58
Parents: fa4b4ab
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Feb 21 20:31:08 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Feb 21 20:31:08 2013 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVAvailability.h        |    8 ++++++++
 CordovaLib/Classes/CDVCommandDelegateImpl.m |    7 ++++++-
 CordovaLib/Classes/CDVCommandQueue.m        |    5 +++++
 3 files changed, 19 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0b408219/CordovaLib/Classes/CDVAvailability.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAvailability.h b/CordovaLib/Classes/CDVAvailability.h
index 33c6799..1d7dfea 100644
--- a/CordovaLib/Classes/CDVAvailability.h
+++ b/CordovaLib/Classes/CDVAvailability.h
@@ -74,3 +74,11 @@
 #else
     #define CDV_DEPRECATED(version, msg) __attribute__((deprecated()))
 #endif
+
+// Enable this to log all exec() calls.
+#define CDV_ENABLE_EXEC_LOGGING 0
+#if CDV_ENABLE_EXEC_LOGGING
+    #define CDV_EXEC_LOG NSLog
+#else
+    #define CDV_EXEC_LOG(...) do {} while (NO)
+#endif

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0b408219/CordovaLib/Classes/CDVCommandDelegateImpl.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandDelegateImpl.m b/CordovaLib/Classes/CDVCommandDelegateImpl.m
index e399289..6d1c667 100644
--- a/CordovaLib/Classes/CDVCommandDelegateImpl.m
+++ b/CordovaLib/Classes/CDVCommandDelegateImpl.m
@@ -55,7 +55,11 @@
 
 - (void)evalJsHelper2:(NSString*)js
 {
+    CDV_EXEC_LOG(@"Exec: evalling: %@", [js substringToIndex:MIN([js length], 160)]);
     NSString* commandsJSON = [_viewController.webView stringByEvaluatingJavaScriptFromString:js];
+    if ([commandsJSON length] > 0) {
+        CDV_EXEC_LOG(@"Exec: Retrieved new exec messages by chaining.");
+    }
 
     [_commandQueue enqueCommandBatch:commandsJSON];
 }
@@ -78,6 +82,7 @@
 
 - (void)sendPluginResult:(CDVPluginResult*)result callbackId:(NSString*)callbackId
 {
+    CDV_EXEC_LOG(@"Exec(%@): Sending result. Status=%@", callbackId, result.status);
     // This occurs when there is are no win/fail callbacks for the call.
     if ([@"INVALID" isEqualToString:callbackId]) {
         return;
@@ -94,7 +99,7 @@
     NSString* js = [NSString stringWithFormat:@"cordova.require('cordova/exec').nativeCallback('%@',%d,%@,%d)",
         callbackId, status, encodedMessage, keepCallback];
 
-    [self evalJsHelper:js];
+    [self evalJsHelper2:js];
 }
 
 - (void)evalJs:(NSString*)js

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0b408219/CordovaLib/Classes/CDVCommandQueue.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandQueue.m b/CordovaLib/Classes/CDVCommandQueue.m
index a5798ac..1ed862a 100644
--- a/CordovaLib/Classes/CDVCommandQueue.m
+++ b/CordovaLib/Classes/CDVCommandQueue.m
@@ -82,6 +82,9 @@
         @"cordova.require('cordova/exec').nativeFetchMessages()"];
 
     [self enqueCommandBatch:queuedCommandsJSON];
+    if ([queuedCommandsJSON length] > 0) {
+        CDV_EXEC_LOG(@"Exec: Retrieved new exec messages by request.");
+    }
 }
 
 - (void)executePending
@@ -100,6 +103,8 @@
             // Iterate over and execute all of the commands.
             for (NSArray* jsonEntry in commandBatch) {
                 CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand commandFromJson:jsonEntry];
+                CDV_EXEC_LOG(@"Exec(%@): Calling %@.%@", command.callbackId, command.className, command.methodName);
+
                 if (![self execute:command]) {
 #ifdef DEBUG
                         NSString* commandJson = [jsonEntry JSONString];