[Libreoffice-commits] online.git: loolwsd/ClientSession.cpp loolwsd/Log.cpp loolwsd/LOOLWSD.hpp loolwsd/TraceFile.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Aug 8 03:47:52 UTC 2016
loolwsd/ClientSession.cpp | 2 ++
loolwsd/LOOLWSD.hpp | 4 ++--
loolwsd/Log.cpp | 1 +
loolwsd/TraceFile.hpp | 11 ++++++++++-
4 files changed, 15 insertions(+), 3 deletions(-)
New commits:
commit 026a22abc36745b9374c7302fc2b27d4ba089cff
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Jul 30 23:06:12 2016 -0400
loolwsd: dump incoming commands
Change-Id: I3d77d0c645c0bdd7e9edfbc8d90d5df6cc1b927a
Reviewed-on: https://gerrit.libreoffice.org/27954
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/ClientSession.cpp b/loolwsd/ClientSession.cpp
index f3c2a00..57da9a6 100644
--- a/loolwsd/ClientSession.cpp
+++ b/loolwsd/ClientSession.cpp
@@ -64,6 +64,8 @@ bool ClientSession::_handleInput(const char *buffer, int length)
StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
Log::trace(getName() + ": handling [" + firstLine + "].");
+ LOOLWSD::dumpIncomingTrace(firstLine);
+
if (LOOLProtocol::tokenIndicatesUserInteraction(tokens[0]))
{
// Keep track of timestamps of incoming client messages that indicate user activity.
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index eed6b70..0b9f6bc 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -62,11 +62,11 @@ public:
}
static
- void dumpTrace(const std::string& data)
+ void dumpIncomingTrace(const std::string& data)
{
if (TraceDumper)
{
- TraceDumper->write(data);
+ TraceDumper->writeIncoming(data);
}
}
diff --git a/loolwsd/Log.cpp b/loolwsd/Log.cpp
index a6511f0..dc3e0da 100644
--- a/loolwsd/Log.cpp
+++ b/loolwsd/Log.cpp
@@ -17,6 +17,7 @@
#include <Poco/ConsoleChannel.h>
#include <Poco/Process.h>
#include <Poco/Thread.h>
+#include <Poco/Timestamp.h>
#include "Log.hpp"
diff --git a/loolwsd/TraceFile.hpp b/loolwsd/TraceFile.hpp
index c1c01d7..9b2d3b9 100644
--- a/loolwsd/TraceFile.hpp
+++ b/loolwsd/TraceFile.hpp
@@ -15,6 +15,7 @@ class TraceFile
{
public:
TraceFile(const std::string& path) :
+ _epochStart(Poco::Timestamp().epochMicroseconds()),
_stream(path, std::ios::out)
{
}
@@ -24,13 +25,21 @@ public:
_stream.close();
}
- void write(const std::string& data)
+ void writeIncoming(const std::string& data)
{
+ std::unique_lock<std::mutex> lock(_mutex);
+ const Poco::Int64 usec = Poco::Timestamp().epochMicroseconds() - _epochStart;
+ _stream.write(">", 1);
+ _stream << usec;
+ _stream.write(">", 1);
_stream.write(data.c_str(), data.size());
+ _stream.write("\n", 1);
}
private:
+ const Poco::Int64 _epochStart;
std::fstream _stream;
+ std::mutex _mutex;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list