net/FakeSocket.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
New commits: commit 763a27280ad84fac1e26a9e0322408c1e7af8819 Author: Tor Lillqvist <[email protected]> AuthorDate: Tue Sep 18 15:27:17 2018 +0300 Commit: Tor Lillqvist <[email protected]> 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 ""; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
