0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00

unit testing: LogOutputCollector: added log_wrapper() method for multi-threaded tests

To enable logging in new threads, add this line to the
beginning of your thread function:

  Log::Context log_context(testLog->log_wrapper());

Signed-off-by: James Yonan <james@openvpn.net>
This commit is contained in:
James Yonan 2020-10-15 22:49:41 -06:00
parent 0657de823e
commit f50bcab9e4

View File

@ -109,12 +109,18 @@ namespace openvpn {
return getOutput();
}
const Log::Context::Wrapper& log_wrapper()
{
return log_wrap;
}
private:
bool output_log = true;
bool collect_log = false;
std::stringstream out;
std::mutex mutex{};
Log::Context log_context;
Log::Context::Wrapper log_wrap; // must be constructed after log_context
};
}