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.
This commit is contained in:
parent
c09dfda052
commit
763a27280a
1 changed files with 6 additions and 1 deletions
|
@ -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 "";
|
||||
|
|
Loading…
Reference in a new issue