[Libreoffice-commits] online.git: 4 commits - common/MessageQueue.cpp ios/Mobile wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Nov 28 23:08:27 UTC 2018


 common/MessageQueue.cpp              |   18 +++++++++---------
 ios/Mobile/Document.mm               |    4 +++-
 ios/Mobile/DocumentViewController.mm |    6 +++++-
 wsd/DocumentBroker.cpp               |    4 ++--
 wsd/DocumentBroker.hpp               |    6 +++---
 5 files changed, 22 insertions(+), 16 deletions(-)

New commits:
commit b4e3110d7b60d6dc58e716d86fb18fe8fed23ba7
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Nov 29 01:01:12 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Nov 29 01:07:03 2018 +0200

    Truncate for logging at a bit higher limit
    
    Change-Id: I352ef6476a9cde767b4076ad9a2ab8cf3c9bdf2b

diff --git a/ios/Mobile/Document.mm b/ios/Mobile/Document.mm
index 720aaab79..241e2cb3d 100644
--- a/ios/Mobile/Document.mm
+++ b/ios/Mobile/Document.mm
@@ -92,7 +92,7 @@
         js = @"window.TheFakeWebSocket.onmessage({'data': Base64ToArrayBuffer('";
         js = [js stringByAppendingString: [[NSData dataWithBytes:buffer length:length] base64EncodedStringWithOptions:0]];
         js = [js stringByAppendingString:@"')});"];
-        NSString *subjs = [js substringToIndex:std::min(40ul, js.length)];
+        NSString *subjs = [js substringToIndex:std::min(100ul, js.length)];
         if (subjs.length < js.length)
             subjs = [subjs stringByAppendingString:@"..."];
 
diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm
index f858a0a5a..f60e31bbc 100644
--- a/ios/Mobile/DocumentViewController.mm
+++ b/ios/Mobile/DocumentViewController.mm
@@ -150,7 +150,7 @@
     } else if ([message.name isEqualToString:@"debug"]) {
         LOG_TRC_NOFILE("==> " << [message.body UTF8String]);
     } else if ([message.name isEqualToString:@"lool"]) {
-        NSString *subBody = [message.body substringToIndex:std::min(40ul, ((NSString*)message.body).length)];
+        NSString *subBody = [message.body substringToIndex:std::min(100ul, ((NSString*)message.body).length)];
         if (subBody.length < ((NSString*)message.body).length)
             subBody = [subBody stringByAppendingString:@"..."];
 
commit 235c9b8a6070c0ffefc0aa5a80534e6f5c9f5af5
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Nov 29 00:57:34 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Nov 29 01:07:03 2018 +0200

    Use getAbbreviatedMessage() for its intended purpose
    
    Don't log a potentially very long message in its entirety.
    
    Change-Id: I01fbf76465d99bbab117d1dcacc6c7239a1da518

diff --git a/common/MessageQueue.cpp b/common/MessageQueue.cpp
index 0a473d0e4..44781d118 100644
--- a/common/MessageQueue.cpp
+++ b/common/MessageQueue.cpp
@@ -31,7 +31,7 @@ void TileQueue::put_impl(const Payload& value)
 
     if (firstToken == "canceltiles")
     {
-        LOG_TRC("Processing [" << msg << "]. Before canceltiles have " << getQueue().size() << " in queue.");
+        LOG_TRC("Processing [" << LOOLProtocol::getAbbreviatedMessage(msg) << "]. Before canceltiles have " << getQueue().size() << " in queue.");
         const std::string seqs = msg.substr(12);
         StringTokenizer tokens(seqs, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
         getQueue().erase(std::remove_if(getQueue().begin(), getQueue().end(),
@@ -119,7 +119,7 @@ void TileQueue::removeTileDuplicate(const std::string& tileMsg)
         if (it.size() > newMsgPos &&
             strncmp(tileMsg.data(), it.data(), newMsgPos) == 0)
         {
-            LOG_TRC("Remove duplicate tile request: " << std::string(it.data(), it.size()) << " -> " << tileMsg);
+            LOG_TRC("Remove duplicate tile request: " << std::string(it.data(), it.size()) << " -> " << LOOLProtocol::getAbbreviatedMessage(tileMsg));
             getQueue().erase(getQueue().begin() + i);
             break;
         }
@@ -334,7 +334,7 @@ std::string TileQueue::removeCallbackDuplicate(const std::string& callbackMsg)
 
             if (unoCommand == queuedUnoCommand)
             {
-                LOG_TRC("Remove obsolete uno command: " << std::string(it.data(), it.size()) << " -> " << callbackMsg);
+                LOG_TRC("Remove obsolete uno command: " << std::string(it.data(), it.size()) << " -> " << LOOLProtocol::getAbbreviatedMessage(callbackMsg));
                 getQueue().erase(getQueue().begin() + i);
                 break;
             }
@@ -371,7 +371,7 @@ std::string TileQueue::removeCallbackDuplicate(const std::string& callbackMsg)
 
             if (!isViewCallback && (queuedTokens[1] == tokens[1] && queuedTokens[2] == tokens[2]))
             {
-                LOG_TRC("Remove obsolete callback: " << std::string(it.data(), it.size()) << " -> " << callbackMsg);
+                LOG_TRC("Remove obsolete callback: " << std::string(it.data(), it.size()) << " -> " << LOOLProtocol::getAbbreviatedMessage(callbackMsg));
                 getQueue().erase(getQueue().begin() + i);
                 break;
             }
@@ -384,7 +384,7 @@ std::string TileQueue::removeCallbackDuplicate(const std::string& callbackMsg)
 
                 if (viewId == queuedViewId)
                 {
-                    LOG_TRC("Remove obsolete view callback: " << std::string(it.data(), it.size()) << " -> " << callbackMsg);
+                    LOG_TRC("Remove obsolete view callback: " << std::string(it.data(), it.size()) << " -> " << LOOLProtocol::getAbbreviatedMessage(callbackMsg));
                     getQueue().erase(getQueue().begin() + i);
                     break;
                 }
@@ -444,7 +444,7 @@ TileQueue::Payload TileQueue::get_impl()
     if (!isTile || isPreview)
     {
         // Don't combine non-tiles or tiles with id.
-        LOG_TRC("MessageQueue res: " << msg);
+        LOG_TRC("MessageQueue res: " << LOOLProtocol::getAbbreviatedMessage(msg));
         getQueue().erase(getQueue().begin());
 
         // de-prioritize the other tiles with id - usually the previews in
@@ -507,7 +507,7 @@ TileQueue::Payload TileQueue::get_impl()
         }
 
         TileDesc tile2 = TileDesc::parse(msg);
-        LOG_TRC("Combining candidate: " << msg);
+        LOG_TRC("Combining candidate: " << LOOLProtocol::getAbbreviatedMessage(msg));
 
         // Check if it's on the same row.
         if (tiles[0].onSameRow(tile2))
@@ -526,12 +526,12 @@ TileQueue::Payload TileQueue::get_impl()
     if (tiles.size() == 1)
     {
         msg = tiles[0].serialize("tile");
-        LOG_TRC("MessageQueue res: " << msg);
+        LOG_TRC("MessageQueue res: " << LOOLProtocol::getAbbreviatedMessage(msg));
         return Payload(msg.data(), msg.data() + msg.size());
     }
 
     std::string tileCombined = TileCombined::create(tiles).serialize("tilecombine");
-    LOG_TRC("MessageQueue res: " << tileCombined);
+    LOG_TRC("MessageQueue res: " << LOOLProtocol::getAbbreviatedMessage(tileCombined));
     return Payload(tileCombined.data(), tileCombined.data() + tileCombined.size());
 }
 
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 5b45a84d9..fed34213e 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1677,7 +1677,7 @@ bool DocumentBroker::forwardToChild(const std::string& viewId, const std::string
         return true;
     }
 
-    LOG_TRC("Forwarding payload to child [" << viewId << "]: " << message);
+    LOG_TRC("Forwarding payload to child [" << viewId << "]: " << getAbbreviatedMessage(message));
 
     std::string msg = "child-" + viewId + ' ' + message;
 
@@ -1701,7 +1701,7 @@ bool DocumentBroker::forwardToChild(const std::string& viewId, const std::string
     }
 
     // try the not yet created sessions
-    LOG_WRN("Child session [" << viewId << "] not found to forward message: " << message);
+    LOG_WRN("Child session [" << viewId << "] not found to forward message: " << getAbbreviatedMessage(message));
 
     return false;
 }
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 6f66bfb58..09ee0e9d6 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -155,7 +155,7 @@ public:
         {
             if (_ws)
             {
-                LOG_TRC("Send DocBroker to Child message: [" << data << "].");
+                LOG_TRC("Send DocBroker to Child message: [" << LOOLProtocol::getAbbreviatedMessage(data) << "].");
                 _ws->sendMessage(data);
                 return true;
             }
@@ -163,11 +163,11 @@ public:
         catch (const std::exception& exc)
         {
             LOG_ERR("Failed to send child [" << _pid << "] data [" <<
-                    data << "] due to: " << exc.what());
+                    LOOLProtocol::getAbbreviatedMessage(data) << "] due to: " << exc.what());
             throw;
         }
 
-        LOG_WRN("No socket between DocBroker and child to send [" << data << "]");
+        LOG_WRN("No socket between DocBroker and child to send [" << LOOLProtocol::getAbbreviatedMessage(data) << "]");
         return false;
     }
 
commit efb883b21c4f75b2fbe2f5c5e926f0f3b3ad29dc
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Nov 29 00:23:39 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Nov 29 01:07:03 2018 +0200

    Truncate received message string for logging if necessary
    
    Change-Id: Id71968227236993e4d181370e68523f2bf6118a7

diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm
index ff65b9a94..f858a0a5a 100644
--- a/ios/Mobile/DocumentViewController.mm
+++ b/ios/Mobile/DocumentViewController.mm
@@ -150,7 +150,11 @@
     } else if ([message.name isEqualToString:@"debug"]) {
         LOG_TRC_NOFILE("==> " << [message.body UTF8String]);
     } else if ([message.name isEqualToString:@"lool"]) {
-        LOG_TRC("To Online: " << [message.body UTF8String]);
+        NSString *subBody = [message.body substringToIndex:std::min(40ul, ((NSString*)message.body).length)];
+        if (subBody.length < ((NSString*)message.body).length)
+            subBody = [subBody stringByAppendingString:@"..."];
+
+        LOG_TRC("To Online: " << [subBody UTF8String]);
 
         if ([message.body isEqualToString:@"HULLO"]) {
             // Now we know that the JS has started completely
commit d361c00937ef6363e7be05856f12b909cd8d3a9f
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Nov 29 00:23:17 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Nov 29 01:02:28 2018 +0200

    Append an ellipsis if the JS string was truncated for logging
    
    Change-Id: I0bc2efff31e5c8d448e07e2457588fc638fb7a8f

diff --git a/ios/Mobile/Document.mm b/ios/Mobile/Document.mm
index 0676fd8ff..720aaab79 100644
--- a/ios/Mobile/Document.mm
+++ b/ios/Mobile/Document.mm
@@ -93,6 +93,8 @@
         js = [js stringByAppendingString: [[NSData dataWithBytes:buffer length:length] base64EncodedStringWithOptions:0]];
         js = [js stringByAppendingString:@"')});"];
         NSString *subjs = [js substringToIndex:std::min(40ul, js.length)];
+        if (subjs.length < js.length)
+            subjs = [subjs stringByAppendingString:@"..."];
 
         // LOG_TRC("Evaluating JavaScript: " << [subjs UTF8String]);
 


More information about the Libreoffice-commits mailing list