[Libreoffice-commits] online.git: net/FakeSocket.cpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Sep 18 12:31:47 UTC 2018
net/FakeSocket.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
New commits:
commit 763a27280ad84fac1e26a9e0322408c1e7af8819
Author: Tor Lillqvist <tml at iki.fi>
AuthorDate: Tue Sep 18 15:27:17 2018 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Sep 18 15:31:01 2018 +0300
Add possiblity to force logging to stderr with environment variable
At least LOOLWSD.cpp has a couple of global variables of types that in
their constructors invoke FakeSocket APIs. If we turn on FakeSocket
logging (fakeSocketSetLoggingCallback()) only in the app's
initialization code, we will miss logging from those global variable
constructors.
Sure, the clean solution would be to turn those global variables into
members in the LOOLWSD class instead, but this will do for now.
diff --git a/net/FakeSocket.cpp b/net/FakeSocket.cpp
index 9c83df4ce..99480dc4d 100644
--- a/net/FakeSocket.cpp
+++ b/net/FakeSocket.cpp
@@ -13,6 +13,8 @@
#include <chrono>
#include <condition_variable>
+#include <cstdlib>
+#include <iostream>
#include <sstream>
#include <mutex>
#include <thread>
@@ -80,7 +82,10 @@ static std::vector<FakeSocketPair>& getFds()
static std::string flush()
{
- if (loggingCallback != nullptr)
+ static bool alwaysStderr = std::getenv("FAKESOCKET_LOG_ALWAYS_STDERR") != nullptr;
+ if (alwaysStderr)
+ std::cerr << loggingBuffer.str() << std::endl;
+ else if (loggingCallback != nullptr)
loggingCallback(loggingBuffer.str());
loggingBuffer.str("");
return "";
More information about the Libreoffice-commits
mailing list