OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::LogOutputCollector Class Reference

#include <test_helper.hpp>

Inheritance diagram for openvpn::LogOutputCollector:
[legend]
Collaboration diagram for openvpn::LogOutputCollector:
[legend]

Public Member Functions

 LogOutputCollector ()
 
void log (const std::string &l) override
 
std::string getOutput () const
 
std::ostream & getStream ()
 
void setPrintOutput (bool doOutput)
 
bool isStdoutEnabled () const
 
void startCollecting ()
 
std::string stopCollecting ()
 
const Log::Context::Wrapperlog_wrapper ()
 
- Public Member Functions inherited from openvpn::RC< thread_safe_refcount >
 RC () noexcept=default
 
 RC (const RC &)=delete
 
virtual ~RC ()=default
 
RCoperator= (const RC &)=delete
 
olong use_count () const noexcept
 Delegates call to RCImpl and returns the result.
 

Private Attributes

bool output_log = true
 
bool collect_log = false
 
std::stringstream out
 
std::mutex mutex {}
 
Log::Context log_context
 
Log::Context::Wrapper log_wrap
 

Additional Inherited Members

- Public Types inherited from openvpn::RC< thread_safe_refcount >
typedef RCPtr< RCPtr
 
- Static Public Member Functions inherited from openvpn::RC< thread_safe_refcount >
static constexpr bool is_thread_safe ()
 Delegates call to RCImpl and returns the result.
 

Detailed Description

Definition at line 28 of file test_helper.hpp.

Constructor & Destructor Documentation

◆ LogOutputCollector()

openvpn::LogOutputCollector::LogOutputCollector ( )
inline

Definition at line 31 of file test_helper.hpp.

Member Function Documentation

◆ getOutput()

std::string openvpn::LogOutputCollector::getOutput ( ) const
inline

Return the collected log out

Returns
the log output as string

Definition at line 50 of file test_helper.hpp.

Here is the caller graph for this function:

◆ getStream()

std::ostream & openvpn::LogOutputCollector::getStream ( )
inline

Allow to access the underlying output stream to direct output from function that want to write to a stream to it

Returns
that will be captured by this log

Definition at line 60 of file test_helper.hpp.

◆ isStdoutEnabled()

bool openvpn::LogOutputCollector::isStdoutEnabled ( ) const
inline

Return current state of stdout output

Returns
current state of output

Definition at line 78 of file test_helper.hpp.

Here is the caller graph for this function:

◆ log()

void openvpn::LogOutputCollector::log ( const std::string &  l)
inlineoverridevirtual

Implements openvpn::LogBase.

Definition at line 36 of file test_helper.hpp.

◆ log_wrapper()

const Log::Context::Wrapper & openvpn::LogOutputCollector::log_wrapper ( )
inline

Definition at line 107 of file test_helper.hpp.

◆ setPrintOutput()

void openvpn::LogOutputCollector::setPrintOutput ( bool  doOutput)
inline

Changes if the logging to stdout should be done

Parameters
doOutput

Definition at line 69 of file test_helper.hpp.

Here is the caller graph for this function:

◆ startCollecting()

void openvpn::LogOutputCollector::startCollecting ( )
inline

Starts collecting log output. This will also disable stdout output and clear the collected output if there is any

Definition at line 87 of file test_helper.hpp.

Here is the caller graph for this function:

◆ stopCollecting()

std::string openvpn::LogOutputCollector::stopCollecting ( )
inline

Stops collecting log output. Will reenable stdout output.

Returns
the output collected

Definition at line 100 of file test_helper.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ collect_log

bool openvpn::LogOutputCollector::collect_log = false
private

Definition at line 114 of file test_helper.hpp.

◆ log_context

Log::Context openvpn::LogOutputCollector::log_context
private

Definition at line 117 of file test_helper.hpp.

◆ log_wrap

Log::Context::Wrapper openvpn::LogOutputCollector::log_wrap
private

Definition at line 118 of file test_helper.hpp.

◆ mutex

std::mutex openvpn::LogOutputCollector::mutex {}
private

Definition at line 116 of file test_helper.hpp.

◆ out

std::stringstream openvpn::LogOutputCollector::out
private

Definition at line 115 of file test_helper.hpp.

◆ output_log

bool openvpn::LogOutputCollector::output_log = true
private

Definition at line 113 of file test_helper.hpp.


The documentation for this class was generated from the following file: