[Libreoffice-commits] online.git: 2 commits - loleaflet/README loolwsd/LOOLWSD.cpp loolwsd/loolwsd.xml.in loolwsd/TraceFile.hpp loolwsd/Util.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Aug 8 03:54:10 UTC 2016


 loleaflet/README       |    5 +++++
 loolwsd/LOOLWSD.cpp    |   18 +++++++++++++++++-
 loolwsd/TraceFile.hpp  |   17 ++++++++++++++---
 loolwsd/Util.hpp       |   21 +++++++++++++++++++--
 loolwsd/loolwsd.xml.in |    3 +++
 5 files changed, 58 insertions(+), 6 deletions(-)

New commits:
commit 045f0b6388c155eb67b4fb2137ea60c5934da2e2
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri Aug 5 11:25:49 2016 -0400

    loleaflet: npm requirement and upgrade instructions added
    
    Change-Id: Id769931cfef8c6c1cc291b12ed399484f6b19f97
    Reviewed-on: https://gerrit.libreoffice.org/27972
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loleaflet/README b/loleaflet/README
index 8daebaf..cfac4c5 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -13,6 +13,11 @@ First you need to install 'jake', and 'browserify'.  As root, do:
 
 npm is provided by the nodejs package.
 
+npm should be at least 2.14, if not 3.x. Use `npm -v` to find the current version.
+Upgrade npm (as root):
+
+    npm install -g npm
+
 Another way is to use npm as a user, but set its prefix to a directory where
 you have write access. If you want that, you need to have an ~/.npmrc with the
 line e.g.
commit a3e9fc81397d83188466373cd04c2bdecaa91f23
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu Aug 4 18:44:24 2016 -0400

    loolstress: filter trace messages by regex config
    
    Change-Id: I13483cd6614e5753a22408102c9cc310a587db2e
    Reviewed-on: https://gerrit.libreoffice.org/27970
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index a8c397a..0a994aa 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1402,7 +1402,23 @@ void LOOLWSD::initialize(Application& self)
     if (getConfigValue<bool>(conf, "trace[@enable]", false))
     {
         const auto& path = getConfigValue<std::string>(conf, "trace.path", "");
-        TraceDumper.reset(new TraceFileWriter(path, getConfigValue<bool>(conf, "trace.outgoing.record", false)));
+        const auto recordOutgoing = getConfigValue<bool>(conf, "trace.outgoing.record", false);
+        std::vector<std::string> filters;
+        for (size_t i = 0; ; ++i)
+        {
+            const std::string confPath = "trace.filter.message[" + std::to_string(i) + "]";
+            const auto regex = config().getString(confPath, "");
+            if (!regex.empty())
+            {
+                filters.push_back(regex);
+            }
+            else if (!config().has(confPath))
+            {
+                break;
+            }
+        }
+
+        TraceDumper.reset(new TraceFileWriter(path, recordOutgoing, filters));
         Log::info("Command trace dumping enabled to file: " + path);
     }
 
diff --git a/loolwsd/TraceFile.hpp b/loolwsd/TraceFile.hpp
index d9b02bf..dec080c 100644
--- a/loolwsd/TraceFile.hpp
+++ b/loolwsd/TraceFile.hpp
@@ -13,6 +13,8 @@
 #include <string>
 #include <vector>
 
+#include "Util.hpp"
+
 /// Dumps commands and notification trace.
 class TraceFileRecord
 {
@@ -40,11 +42,16 @@ public:
 class TraceFileWriter
 {
 public:
-    TraceFileWriter(const std::string& path, const bool recordOugoing) :
+    TraceFileWriter(const std::string& path, const bool recordOugoing, const std::vector<std::string>& filters) :
         _epochStart(Poco::Timestamp().epochMicroseconds()),
         _recordOutgoing(recordOugoing),
+        _filter(true),
         _stream(path, std::ios::out)
     {
+        for (const auto& f : filters)
+        {
+            _filter.deny(f);
+        }
     }
 
     ~TraceFileWriter()
@@ -59,12 +66,15 @@ public:
 
     void writeIncoming(const std::string& pId, const std::string& sessionId, const std::string& data)
     {
-        write(pId, sessionId, data, static_cast<char>(TraceFileRecord::Direction::Incoming));
+        if (_filter.match(data))
+        {
+            write(pId, sessionId, data, static_cast<char>(TraceFileRecord::Direction::Incoming));
+        }
     }
 
     void writeOutgoing(const std::string& pId, const std::string& sessionId, const std::string& data)
     {
-        if (_recordOutgoing)
+        if (_recordOutgoing && _filter.match(data))
         {
             write(pId, sessionId, data, static_cast<char>(TraceFileRecord::Direction::Outgoing));
         }
@@ -89,6 +99,7 @@ private:
 private:
     const Poco::Int64 _epochStart;
     const bool _recordOutgoing;
+    Util::RegexListMatcher _filter;
     std::fstream _stream;
     std::mutex _mutex;
 };
diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp
index 1bbd377..f3425fe 100644
--- a/loolwsd/Util.hpp
+++ b/loolwsd/Util.hpp
@@ -114,22 +114,37 @@ namespace Util
     class RegexListMatcher
     {
     public:
-        RegexListMatcher()
+        RegexListMatcher() :
+            _allowByDefault(false)
+        {
+        }
+
+        RegexListMatcher(const bool allowByDefault) :
+            _allowByDefault(allowByDefault)
         {
         }
 
         RegexListMatcher(std::initializer_list<std::string> allowed) :
+            _allowByDefault(false),
             _allowed(allowed)
         {
         }
 
         RegexListMatcher(std::initializer_list<std::string> allowed,
                          std::initializer_list<std::string> denied) :
+            _allowByDefault(false),
             _allowed(allowed),
             _denied(denied)
         {
         }
 
+        RegexListMatcher(const bool allowByDefault,
+                         std::initializer_list<std::string> denied) :
+            _allowByDefault(allowByDefault),
+            _denied(denied)
+        {
+        }
+
         void allow(const std::string& pattern) { _allowed.insert(pattern); }
         void deny(const std::string& pattern)
         {
@@ -145,7 +160,8 @@ namespace Util
 
         bool match(const std::string& subject) const
         {
-            return (match(_allowed, subject) && !match(_denied, subject));
+            return (_allowByDefault || match(_allowed, subject)) &&
+                    !match(_denied, subject);
         }
 
     private:
@@ -181,6 +197,7 @@ namespace Util
         }
 
     private:
+        const bool _allowByDefault;
         std::set<std::string> _allowed;
         std::set<std::string> _denied;
     };
diff --git a/loolwsd/loolwsd.xml.in b/loolwsd/loolwsd.xml.in
index 1267210..6acfdf6 100644
--- a/loolwsd/loolwsd.xml.in
+++ b/loolwsd/loolwsd.xml.in
@@ -25,6 +25,9 @@
 
     <trace desc="Dump commands and notifications for replay" enable="true">
         <path desc="Output file path">/tmp/dump</path>
+        <filter>
+            <message desc="Regex pattern of messages to exlcude">tile.*</message>
+        </filter>
         <outgoing>
             <record desc="Whether or not to record outgoing messages" default="false">false</record>
         </outgoing>


More information about the Libreoffice-commits mailing list