xrpld
Loading...
Searching...
No Matches
xrpl::test::CaptureLogs Class Reference

Log manager for CaptureSinks. More...

#include <CaptureLogs.h>

Inheritance diagram for xrpl::test::CaptureLogs:
Collaboration diagram for xrpl::test::CaptureLogs:

Classes

class  CaptureSink
 sink for writing all log messages to a stringstream More...

Public Member Functions

 CaptureLogs (std::string *pResult)
 ~CaptureLogs () override
std::unique_ptr< beast::Journal::SinkmakeSink (std::string const &partition, beast::Severity threshold) override
bool open (boost::filesystem::path const &pathToLogFile)
beast::Journal::Sinkget (std::string const &name)
beast::Journal::Sinkoperator[] (std::string const &name)
beast::Journal journal (std::string const &name)
beast::Severity threshold () const
void threshold (beast::Severity thresh)
std::vector< std::pair< std::string, std::string > > partitionSeverities () const
void write (beast::Severity level, std::string const &partition, std::string const &text, bool console)
std::string rotate ()
void silent (bool bSilent)
 Set flag to write logs to stderr (false) or not (true).

Static Public Member Functions

static std::string toString (beast::Severity s)
static std::optional< beast::SeverityfromString (std::string const &s)

Static Private Member Functions

static void format (std::string &output, std::string const &message, beast::Severity severity, std::string const &partition)

Private Attributes

std::mutex strmMutex_
std::stringstream strm_
std::stringpResult_
std::mutex mutex_
std::map< std::string, std::unique_ptr< beast::Journal::Sink >, boost::beast::iless > sinks_
beast::Severity thresh_
File file_
bool silent_ = false

Static Private Attributes

static constexpr auto kMaximumMessageCharacters = 12 * 1024

Detailed Description

Log manager for CaptureSinks.

This class holds the stream instance that is written to by the sinks. Upon destruction, all contents of the stream are assigned to the string specified in the ctor

Definition at line 13 of file CaptureLogs.h.

Constructor & Destructor Documentation

◆ CaptureLogs()

xrpl::test::CaptureLogs::CaptureLogs ( std::string * pResult)
explicit

Definition at line 49 of file CaptureLogs.h.

◆ ~CaptureLogs()

xrpl::test::CaptureLogs::~CaptureLogs ( )
override

Definition at line 53 of file CaptureLogs.h.

Member Function Documentation

◆ makeSink()

std::unique_ptr< beast::Journal::Sink > xrpl::test::CaptureLogs::makeSink ( std::string const & partition,
beast::Severity threshold )
overridevirtual

Reimplemented from xrpl::Logs.

Definition at line 59 of file CaptureLogs.h.

◆ open()

bool xrpl::Logs::open ( boost::filesystem::path const & pathToLogFile)
inherited

Definition at line 117 of file Log.cpp.

◆ get()

beast::Journal::Sink & xrpl::Logs::get ( std::string const & name)
inherited

Definition at line 123 of file Log.cpp.

◆ operator[]()

beast::Journal::Sink & xrpl::Logs::operator[] ( std::string const & name)
inherited

Definition at line 131 of file Log.cpp.

◆ journal()

beast::Journal xrpl::Logs::journal ( std::string const & name)
inherited

Definition at line 137 of file Log.cpp.

◆ threshold() [1/2]

beast::Severity xrpl::Logs::threshold ( ) const
inherited

Definition at line 143 of file Log.cpp.

◆ threshold() [2/2]

void xrpl::Logs::threshold ( beast::Severity thresh)
inherited

Definition at line 149 of file Log.cpp.

◆ partitionSeverities()

std::vector< std::pair< std::string, std::string > > xrpl::Logs::partitionSeverities ( ) const
inherited

Definition at line 158 of file Log.cpp.

◆ write()

void xrpl::Logs::write ( beast::Severity level,
std::string const & partition,
std::string const & text,
bool console )
inherited

Definition at line 169 of file Log.cpp.

◆ rotate()

std::string xrpl::Logs::rotate ( )
inherited

Definition at line 187 of file Log.cpp.

◆ silent()

void xrpl::Logs::silent ( bool bSilent)
inherited

Set flag to write logs to stderr (false) or not (true).

Parameters
bSilentSet flag accordingly.

Definition at line 176 of file Log.h.

◆ toString()

std::string xrpl::Logs::toString ( beast::Severity s)
staticinherited

Definition at line 203 of file Log.cpp.

◆ fromString()

std::optional< beast::Severity > xrpl::Logs::fromString ( std::string const & s)
staticinherited

Definition at line 228 of file Log.cpp.

◆ format()

void xrpl::Logs::format ( std::string & output,
std::string const & message,
beast::Severity severity,
std::string const & partition )
staticprivateinherited

Definition at line 252 of file Log.cpp.

Member Data Documentation

◆ strmMutex_

std::mutex xrpl::test::CaptureLogs::strmMutex_
private

Definition at line 15 of file CaptureLogs.h.

◆ strm_

std::stringstream xrpl::test::CaptureLogs::strm_
private

Definition at line 16 of file CaptureLogs.h.

◆ pResult_

std::string* xrpl::test::CaptureLogs::pResult_
private

Definition at line 17 of file CaptureLogs.h.

◆ mutex_

std::mutex xrpl::Logs::mutex_
mutableprivateinherited

Definition at line 124 of file Log.h.

◆ sinks_

std::map<std::string, std::unique_ptr<beast::Journal::Sink>, boost::beast::iless> xrpl::Logs::sinks_
privateinherited

Definition at line 125 of file Log.h.

◆ thresh_

beast::Severity xrpl::Logs::thresh_
privateinherited

Definition at line 126 of file Log.h.

◆ file_

File xrpl::Logs::file_
privateinherited

Definition at line 127 of file Log.h.

◆ silent_

bool xrpl::Logs::silent_ = false
privateinherited

Definition at line 128 of file Log.h.

◆ kMaximumMessageCharacters

auto xrpl::Logs::kMaximumMessageCharacters = 12 * 1024
staticconstexprprivateinherited

Definition at line 194 of file Log.h.