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
ripple::test::CaptureLogs Class Reference

Log manager for CaptureSinks. More...

#include <CaptureLogs.h>

Inheritance diagram for ripple::test::CaptureLogs:
Inheritance graph
[legend]
Collaboration diagram for ripple::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 15 of file CaptureLogs.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
privateinherited
Enumerator
maximumMessageCharacters 

Definition at line 222 of file Log.h.

Constructor & Destructor Documentation

◆ CaptureLogs()

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

Definition at line 58 of file CaptureLogs.h.

◆ ~CaptureLogs()

ripple::test::CaptureLogs::~CaptureLogs ( )
override

Definition at line 63 of file CaptureLogs.h.

Member Function Documentation

◆ makeSink()

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

Reimplemented from ripple::Logs.

Definition at line 69 of file CaptureLogs.h.

◆ open()

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

Definition at line 121 of file Log.cpp.

◆ get()

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

Definition at line 127 of file Log.cpp.

◆ operator[]()

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

Definition at line 135 of file Log.cpp.

◆ journal()

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

Definition at line 141 of file Log.cpp.

◆ threshold() [1/2]

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

Definition at line 147 of file Log.cpp.

◆ threshold() [2/2]

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

Definition at line 153 of file Log.cpp.

◆ partition_severities()

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

Definition at line 162 of file Log.cpp.

◆ write()

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

Definition at line 173 of file Log.cpp.

◆ rotate()

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

Definition at line 191 of file Log.cpp.

◆ silent()

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

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

Parameters
bSilentSet flag accordingly.

Definition at line 198 of file Log.h.

◆ fromSeverity()

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

Definition at line 207 of file Log.cpp.

◆ toSeverity()

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

Definition at line 236 of file Log.cpp.

◆ toString()

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

Definition at line 264 of file Log.cpp.

◆ fromString()

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

Definition at line 289 of file Log.cpp.

◆ format()

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

Definition at line 314 of file Log.cpp.

Member Data Documentation

◆ strmMutex_

std::mutex ripple::test::CaptureLogs::strmMutex_
private

Definition at line 17 of file CaptureLogs.h.

◆ strm_

std::stringstream ripple::test::CaptureLogs::strm_
private

Definition at line 18 of file CaptureLogs.h.

◆ pResult_

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

Definition at line 19 of file CaptureLogs.h.

◆ mutex_

std::mutex ripple::Logs::mutex_
mutableprivateinherited

Definition at line 142 of file Log.h.

◆ sinks_

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

Definition at line 147 of file Log.h.

◆ thresh_

beast::severities::Severity ripple::Logs::thresh_
privateinherited

Definition at line 148 of file Log.h.

◆ file_

File ripple::Logs::file_
privateinherited

Definition at line 149 of file Log.h.

◆ silent_

bool ripple::Logs::silent_ = false
privateinherited

Definition at line 150 of file Log.h.