[Libreoffice-commits] online.git: loolwsd/LOOLSession.cpp loolwsd/LOOLSession.hpp loolwsd/Util.cpp

Mihai Varga mihai.varga at collabora.com
Mon Jul 20 02:55:38 PDT 2015


 loolwsd/LOOLSession.cpp |   15 ++++++++++++---
 loolwsd/LOOLSession.hpp |    2 ++
 loolwsd/Util.cpp        |    6 +++---
 3 files changed, 17 insertions(+), 6 deletions(-)

New commits:
commit 19d6dec3f71cc3ef7bead808bbba744312231185
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Mon Jul 20 12:54:08 2015 +0300

    loolwsd: log timestamp in microseconds
    
    Also, separate messages by comma so we can parse them easily

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 000b319..69dccc7 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -85,6 +85,15 @@ LOOLSession::LOOLSession(std::shared_ptr<WebSocket> ws, Kind kind) :
     _docURL("")
 {
     std::cout << Util::logPrefix() << "LOOLSession ctor this=" << this << " " << _kind << " ws=" << _ws.get() << std::endl;
+    if (kind == Kind::ToClient) {
+        _kindString = "ToClient";
+    }
+    else if (kind == Kind::ToMaster) {
+        _kindString = "ToMaster";
+    }
+    else if (kind == Kind::ToPrisoner) {
+        _kindString = "ToPrisoner";
+    }
 }
 
 LOOLSession::~LOOLSession()
@@ -143,7 +152,7 @@ MasterProcessSession::~MasterProcessSession()
 
 bool MasterProcessSession::handleInput(const char *buffer, int length)
 {
-    Application::instance().logger().information(Util::logPrefix() + "Input: " + getAbbreviatedMessage(buffer, length));
+    Application::instance().logger().information(Util::logPrefix() + _kindString + ",Input," + getAbbreviatedMessage(buffer, length));
 
     std::string firstLine = getFirstLine(buffer, length);
     StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
@@ -555,7 +564,7 @@ void MasterProcessSession::dispatchChild()
 
 void MasterProcessSession::forwardToPeer(const char *buffer, int length)
 {
-    Application::instance().logger().information(Util::logPrefix() + "forwardToPeer(" + getAbbreviatedMessage(buffer, length) + ")");
+    Application::instance().logger().information(Util::logPrefix() + _kindString + ",forwardToPeer," + getAbbreviatedMessage(buffer, length));
     auto peer = _peer.lock();
     if (!peer)
         return;
@@ -583,7 +592,7 @@ bool ChildProcessSession::handleInput(const char *buffer, int length)
     std::string firstLine = getFirstLine(buffer, length);
     StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
 
-    Application::instance().logger().information(Util::logPrefix() + "Input: " + getAbbreviatedMessage(buffer, length));
+    Application::instance().logger().information(Util::logPrefix() + _kindString + ",Input," + getAbbreviatedMessage(buffer, length));
 
     if (tokens[0] == "load")
     {
diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp
index a5381ca..aa3ac25 100644
--- a/loolwsd/LOOLSession.hpp
+++ b/loolwsd/LOOLSession.hpp
@@ -55,6 +55,8 @@ protected:
 
     const Kind _kind;
 
+    std::string _kindString;
+
     void sendBinaryFrame(const char *buffer, int length);
 
     virtual bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens) = 0;
diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index 4bdf94e..85bae00 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -51,9 +51,9 @@ namespace Util
 
     std::string logPrefix()
     {
-        static Poco::Timestamp firstTimeStamp;
-        Poco::Int64 now = firstTimeStamp.elapsed();
-        return std::to_string(Poco::Process::id()) + ":" + (Poco::Thread::current() ? std::to_string(Poco::Thread::current()->id()) : "0") + ":" + std::to_string(now / 1000000) + "." + Poco::format("%03d", (int)((now / 1000) % 1000)) + ": ";
+        Poco::Timestamp timeStamp;
+        Poco::Int64 now = timeStamp.epochMicroseconds();
+        return std::to_string(Poco::Process::id()) + "," + (Poco::Thread::current() ? std::to_string(Poco::Thread::current()->id()) : "0") + "," + std::to_string(now / 1000) + ",";
     }
 
     bool windowingAvailable()


More information about the Libreoffice-commits mailing list