[Libreoffice-commits] online.git: 3 commits - Mobile/Mobile Mobile/Mobile.xcodeproj

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Nov 6 15:42:23 UTC 2018


 Mobile/Mobile.xcodeproj/project.pbxproj |    1 
 Mobile/Mobile/AppDelegate.mm            |   11 ++++++---
 Mobile/Mobile/Document.mm               |   10 ++++----
 Mobile/Mobile/DocumentViewController.mm |   37 ++++++++++++++++----------------
 4 files changed, 33 insertions(+), 26 deletions(-)

New commits:
commit 91ef6734449f607791ebbe0c250c0556870c7993
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Nov 6 17:39:38 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Nov 6 17:41:44 2018 +0200

    Change NSLog() calls to Online's LOG_TRC() etc macros
    
    Possibly we should make LOG_ERR and worse on iOS also do a NSLog()
    call, to get such messages into the log the system collects?
    
    Change-Id: Ie3be490966da9133286440c1de90b72befba773a

diff --git a/Mobile/Mobile/AppDelegate.mm b/Mobile/Mobile/AppDelegate.mm
index e02bb32ab..b40c4b86a 100644
--- a/Mobile/Mobile/AppDelegate.mm
+++ b/Mobile/Mobile/AppDelegate.mm
@@ -55,7 +55,7 @@ static LOOLWSD *loolwsd = nullptr;
                            loolwsd = new LOOLWSD();
                            loolwsd->run(1, argv);
                            delete loolwsd;
-                           NSLog(@"One run of LOOLWSD completed");
+                           LOG_TRC("One run of LOOLWSD completed");
                        }
                    });
     return YES;
@@ -94,7 +94,7 @@ static LOOLWSD *loolwsd = nullptr;
     [documentBrowserViewController revealDocumentAtURL:inputURL importIfNeeded:YES completion:^(NSURL * _Nullable revealedDocumentURL, NSError * _Nullable error) {
         if (error) {
             // Handle the error appropriately
-            NSLog(@"Failed to reveal the document at URL %@ with error: '%@'", inputURL, error);
+            LOG_ERR("Failed to reveal the document at URL " << [[inputURL description] UTF8String] << " with error: " << [[error description] UTF8String]);
             return;
         }
 
diff --git a/Mobile/Mobile/Document.mm b/Mobile/Mobile/Document.mm
index 1b742bc2b..bbd20d16d 100644
--- a/Mobile/Mobile/Document.mm
+++ b/Mobile/Mobile/Document.mm
@@ -47,7 +47,7 @@
 }
 
 - (void)send2JS:(const char *)buffer length:(int)length {
-    NSLog(@"send to JS: %s", LOOLProtocol::getAbbreviatedMessage(buffer, length).c_str());
+    LOG_TRC("To JS: " << LOOLProtocol::getAbbreviatedMessage(buffer, length).c_str());
 
     NSString *js;
 
@@ -65,14 +65,14 @@
         js = [js stringByAppendingString:@"')});"];
         NSString *subjs = [js substringToIndex:std::min(40ul, js.length)];
 
-        // NSLog(@"Evaluating JavaScript: %@ (length %lu)", subjs, (unsigned long)js.length);
+        // LOG_TRC("Evaluating JavaScript: " << [subjs UTF8String]);
 
         dispatch_async(dispatch_get_main_queue(), ^{
                 [self.viewController.webView evaluateJavaScript:js
                                               completionHandler:^(id _Nullable obj, NSError * _Nullable error)
                      {
                          if (error) {
-                             NSLog(@"error after %@ (length %lu): %@", subjs, (unsigned long)js.length, error.localizedDescription);
+                             LOG_ERR("Error after " << [subjs UTF8String] << ": " << [error.localizedDescription UTF8String]);
                          }
                      }
                  ];
@@ -96,14 +96,14 @@
         js = [js stringByAppendingString:[NSString stringWithUTF8String:data.data()]];
         js = [js stringByAppendingString:@"'});"];
 
-        // NSLog(@"Evaluating JavaScript: %@", js);
+        // LOG_TRC("Evaluating JavaScript: " << [js UTF8String]);
 
         dispatch_async(dispatch_get_main_queue(), ^{
                 [self.viewController.webView evaluateJavaScript:js
                                               completionHandler:^(id _Nullable obj, NSError * _Nullable error)
                      {
                          if (error) {
-                             NSLog(@"error after %@: %@: %@", js, error.localizedDescription, error.userInfo[@"WKJavaScriptExceptionMessage"]);
+                             LOG_ERR("Error after " << [js UTF8String] << ": " << [error.userInfo[@"WKJavaScriptExceptionMessage"] UTF8String]);
                          }
                      }
                  ];
diff --git a/Mobile/Mobile/DocumentViewController.mm b/Mobile/Mobile/DocumentViewController.mm
index 32f211c5e..f706af0c5 100644
--- a/Mobile/Mobile/DocumentViewController.mm
+++ b/Mobile/Mobile/DocumentViewController.mm
@@ -15,6 +15,7 @@
 
 #import "ios.h"
 #import "FakeSocket.hpp"
+#import "Log.hpp"
 #import "Util.hpp"
 
 #import "DocumentViewController.h"
@@ -75,52 +76,52 @@
 - (IBAction)dismissDocumentViewController {
     [self dismissViewControllerAnimated:YES completion:^ {
             [self.document closeWithCompletionHandler:^(BOOL success){
-                    NSLog(@"close completion handler gets %s", (success?"YES":"NO"));
+                    LOG_TRC("close completion handler gets " << (success?"YES":"NO"));
                     }];
     }];
 }
 
 - (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation {
-    NSLog(@"didCommitNavigation: %@", navigation);
+    LOG_TRC("didCommitNavigation: " << [[navigation description] UTF8String]);
 }
 
 - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
-    NSLog(@"didFailNavigation: %@", navigation);
+    LOG_TRC("didFailNavigation: " << [[navigation description] UTF8String]);
 }
 
 - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
-    NSLog(@"didFailProvisionalNavigation: %@", navigation);
+    LOG_TRC("didFailProvisionalNavigation: " << [[navigation description] UTF8String]);
 }
 
 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
-    NSLog(@"didFinishNavigation: %@", navigation);
+    LOG_TRC("didFinishNavigation: " << [[navigation description] UTF8String]);
 }
 
 - (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation {
-    NSLog(@"didReceiveServerRedirectForProvisionalNavigation: %@", navigation);
+    LOG_TRC("didReceiveServerRedirectForProvisionalNavigation: " << [[navigation description] UTF8String]);
 }
 
 - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
-    NSLog(@"didStartProvisionalNavigation: %@", navigation);
+    LOG_TRC("didStartProvisionalNavigation: " << [[navigation description] UTF8String]);
 }
 
 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
-    NSLog(@"decidePolicyForNavigationAction: %@", navigationAction);
+    LOG_TRC("decidePolicyForNavigationAction: " << [[navigationAction description] UTF8String]);
     decisionHandler(WKNavigationActionPolicyAllow);
 }
 
 - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler {
-    NSLog(@"decidePolicyForNavigationResponse: %@", navigationResponse);
+    LOG_TRC("decidePolicyForNavigationResponse: " << [[navigationResponse description] UTF8String]);
     decisionHandler(WKNavigationResponsePolicyAllow);
 }
 
 - (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures {
-    NSLog(@"createWebViewWithConfiguration");
+    LOG_TRC("createWebViewWithConfiguration");
     return webView;
 }
 
 - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler {
-    NSLog(@"runJavaScriptAlertPanelWithMessage: %@", message);
+    LOG_TRC("runJavaScriptAlertPanelWithMessage: " << [message UTF8String]);
     //    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""
     //                                                    message:message
     //                                                   delegate:nil
@@ -131,12 +132,12 @@
 }
 
 - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler {
-    NSLog(@"runJavaScriptConfirmPanelWithMessage: %@", message);
+    LOG_TRC("runJavaScriptConfirmPanelWithMessage: " << [message UTF8String]);
     completionHandler(YES);
 }
 
 - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *result))completionHandler {
-    NSLog(@"runJavaScriptTextInputPanelWithPrompt: %@", prompt);
+    LOG_TRC("runJavaScriptTextInputPanelWithPrompt: " << [prompt UTF8String]);
     completionHandler(@"Something happened.");
 }
 
@@ -145,11 +146,11 @@
     struct pollfd p;
 
     if ([message.name isEqualToString:@"error"]) {
-        NSLog(@"Error from WebView: %@", message.body);
+        LOG_ERR("Error from WebView: " << [message.body UTF8String]);
     } else if ([message.name isEqualToString:@"debug"]) {
-        NSLog(@"===== %@", message.body);
+        LOG_DBG([message.body UTF8String]);
     } else if ([message.name isEqualToString:@"lool"]) {
-        NSLog(@"===== To Online: %@", message.body);
+        LOG_TRC("To Online: " << [message.body UTF8String]);
 
         if ([message.body isEqualToString:@"HULLO"]) {
             // Now we know that the JS has started completely
@@ -214,7 +215,7 @@
 
             return;
         } else if ([message.body isEqualToString:@"BYE"]) {
-            NSLog(@"document window terminating on JavaScript side. Closing our end of the socket.");
+            LOG_TRC("Document window terminating on JavaScript side. Closing our end of the socket.");
 
             // Close one end of the socket pair, that will wake up the forwarding thread above
             fakeSocketClose(closeNotificationPipeForForwardingThread[0]);
@@ -229,7 +230,7 @@
         fakeSocketPoll(&p, 1, -1);
         fakeSocketWrite(self.document->fakeClientFd, buf, strlen(buf));
     } else {
-        NSLog(@"Unrecognized kind of message received from WebView: %@: %@", message.name, message.body);
+        LOG_ERR("Unrecognized kind of message received from WebView: " << [message.name UTF8String] << ":" << [message.body UTF8String]);
     }
 }
 
commit d07d0517f1dbca039d59fddd6cc7cbefd49ba9f2
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Nov 6 17:19:46 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Nov 6 17:41:44 2018 +0200

    Look for "LOOL_LOGLEVEL" environment variable, Default to "warning"
    
    Change-Id: I83d8cf7eeeed63de3789b5fe8bcb88abeed68a67

diff --git a/Mobile/Mobile/AppDelegate.mm b/Mobile/Mobile/AppDelegate.mm
index aef56be1e..e02bb32ab 100644
--- a/Mobile/Mobile/AppDelegate.mm
+++ b/Mobile/Mobile/AppDelegate.mm
@@ -9,6 +9,7 @@
 #import "config.h"
 
 #import <cassert>
+#import <cstdlib>
 #import <cstring>
 
 #import "AppDelegate.h"
@@ -32,7 +33,11 @@ static LOOLWSD *loolwsd = nullptr;
 }
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
-    Log::initialize("Mobile", "trace", false, false, {});
+    auto trace = std::getenv("LOOL_LOGLEVEL");
+    if (!trace)
+        trace = strdup("warning");
+
+    Log::initialize("Mobile", trace, false, false, {});
     Util::setThreadName("main");
     fakeSocketSetLoggingCallback([](const std::string& line)
                                  {
commit 495a4ee609fd70075befee8082f9cf710b50d9e6
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Mon Nov 5 20:47:41 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Nov 6 17:41:44 2018 +0200

    Define LOSRCDIR in the Relase configuration, too
    
    Change-Id: Ida42481637270d5a8c4f5f0c2a1603a0248f8bdc

diff --git a/Mobile/Mobile.xcodeproj/project.pbxproj b/Mobile/Mobile.xcodeproj/project.pbxproj
index 12d12e25f..4e5e98948 100644
--- a/Mobile/Mobile.xcodeproj/project.pbxproj
+++ b/Mobile/Mobile.xcodeproj/project.pbxproj
@@ -1447,6 +1447,7 @@
 				GCC_WARN_UNUSED_FUNCTION = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				IPHONEOS_DEPLOYMENT_TARGET = 11.4;
+				LOSRCDIR = "$(SOURCE_ROOT)/../../ios-device";
 				MTL_ENABLE_DEBUG_INFO = NO;
 				SDKROOT = iphoneos;
 				VALIDATE_PRODUCT = YES;


More information about the Libreoffice-commits mailing list