rippled
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Types | Static Private Member Functions | Private Attributes | List of all members
xrpl::test::CaptureLogs Class Reference

Log manager for CaptureSinks. More...

#include <CaptureLogs.h>

Inheritance diagram for xrpl::test::CaptureLogs:
Inheritance graph
[legend]
Collaboration diagram for xrpl::test::CaptureLogs:
Collaboration graph
[legend]

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::severities::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::severities::Severity threshold () const
 
void threshold (beast::severities::Severity thresh)
 
std::vector< std::pair< std::string, std::string > > partition_severities () const
 
void write (beast::severities::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 LogSeverity fromSeverity (beast::severities::Severity level)
 
static beast::severities::Severity toSeverity (LogSeverity level)
 
static std::string toString (LogSeverity s)
 
static LogSeverity fromString (std::string const &s)
 

Private Types

enum  { maximumMessageCharacters = 12 * 1024 }
 

Static Private Member Functions

static void format (std::string &output, std::string const &message, beast::severities::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::severities::Severity thresh_
 
File file_
 
bool silent_ = false
 

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 14 of file CaptureLogs.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
privateinherited
Enumerator
maximumMessageCharacters 

Definition at line 206 of file Log.h.

Constructor & Destructor Documentation

◆ CaptureLogs()

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

Definition at line 50 of file CaptureLogs.h.

◆ ~CaptureLogs()

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

Definition at line 54 of file CaptureLogs.h.

Member Function Documentation

◆ makeSink()

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

Reimplemented from xrpl::Logs.

Definition at line 60 of file CaptureLogs.h.

◆ open()

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

Definition at line 114 of file Log.cpp.

◆ get()

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

Definition at line 120 of file Log.cpp.

◆ operator[]()

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

Definition at line 128 of file Log.cpp.

◆ journal()

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

Definition at line 134 of file Log.cpp.

◆ threshold() [1/2]

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

Definition at line 140 of file Log.cpp.

◆ threshold() [2/2]

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

Definition at line 146 of file Log.cpp.

◆ partition_severities()

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

Definition at line 155 of file Log.cpp.

◆ write()

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

Definition at line 166 of file Log.cpp.

◆ rotate()

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

Definition at line 180 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 184 of file Log.h.

◆ fromSeverity()

LogSeverity xrpl::Logs::fromSeverity ( beast::severities::Severity  level)
staticinherited

Definition at line 196 of file Log.cpp.

◆ toSeverity()

beast::severities::Severity xrpl::Logs::toSeverity ( LogSeverity  level)
staticinherited

Definition at line 225 of file Log.cpp.

◆ toString()

std::string xrpl::Logs::toString ( LogSeverity  s)
staticinherited

Definition at line 253 of file Log.cpp.

◆ fromString()

LogSeverity xrpl::Logs::fromString ( std::string const &  s)
staticinherited

Definition at line 278 of file Log.cpp.

◆ format()

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

Definition at line 302 of file Log.cpp.

Member Data Documentation

◆ strmMutex_

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

Definition at line 16 of file CaptureLogs.h.

◆ strm_

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

Definition at line 17 of file CaptureLogs.h.

◆ pResult_

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

Definition at line 18 of file CaptureLogs.h.

◆ mutex_

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

Definition at line 136 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 137 of file Log.h.

◆ thresh_

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

Definition at line 138 of file Log.h.

◆ file_

File xrpl::Logs::file_
privateinherited

Definition at line 139 of file Log.h.

◆ silent_

bool xrpl::Logs::silent_ = false
privateinherited

Definition at line 140 of file Log.h.