Kea 2.7.7
isc::dhcp::LegalLogMgr Class Referenceabstract

LegalLogMgr abstract class. More...

#include <legal_log_mgr.h>

Public Member Functions

 LegalLogMgr (const isc::db::DatabaseConnection::ParameterMap parameters)
 Constructor.
 
virtual ~LegalLogMgr ()=default
 Destructor.
 
virtual void close ()=0
 Closes the store.
 
virtual struct tm currentTimeInfo () const
 Returns the current local date and time.
 
virtual std::string getNowString () const
 Returns the current date and time as string.
 
virtual std::string getNowString (const std::string &format) const
 Returns the current date and time as a string using a specific strftime format string.
 
virtual isc::db::DatabaseConnection::ParameterMap getParameters () const
 Return backend parameters.
 
isc::dhcp::ExpressionPtr getRequestFormatExpression ()
 Gets request extended format expression for custom logging.
 
isc::dhcp::ExpressionPtr getResponseFormatExpression ()
 Gets response extended format expression for custom logging.
 
std::string getTimestampFormat ()
 Gets the timestamp format used for logging.
 
virtual std::string getType () const =0
 Return backend type.
 
virtual bool isUnusable ()
 Flag which indicates if the forensic log backend has at least one unusable connection.
 
virtual struct timespec now () const
 Returns the current system time.
 
virtual void open ()=0
 Opens the store.
 
virtual void setParameters (isc::db::DatabaseConnection::ParameterMap parameters)
 Sets backend parameters.
 
void setRequestFormatExpression (const std::string &extended_format)
 Sets request extended format expression for custom logging.
 
void setResponseFormatExpression (const std::string &extended_format)
 Sets response extended format expression for custom logging.
 
void setTimestampFormat (const std::string &timestamp_format)
 Sets the timestamp format used for logging.
 
virtual void writeln (const std::string &text, const std::string &addr)=0
 Appends a string to the store with a timestamp and address.
 

Static Public Member Functions

static std::string genDurationString (const uint32_t secs)
 Translates seconds into a text string of days, hours, minutes and seconds.
 
static std::string getTimeString (const struct timespec &time, const std::string &format)
 Returns a time as string.
 
static void parseConfig (const isc::data::ConstElementPtr &parameters, isc::db::DatabaseConnection::ParameterMap &map)
 Parse database specification.
 
static void parseDatabase (const isc::data::ConstElementPtr &parameters, isc::db::DatabaseConnection::ParameterMap &map)
 Parse database specification.
 
static void parseExtraParameters (const isc::data::ConstElementPtr &parameters, isc::db::DatabaseConnection::ParameterMap &map)
 Parse extra parameters which are not related to backend connection.
 
static void parseFile (const isc::data::ConstElementPtr &parameters, isc::db::DatabaseConnection::ParameterMap &map)
 Parse file specification.
 
static std::string vectorDump (const std::vector< uint8_t > &bytes)
 Creates a string from a vector of printable bytes.
 
static std::string vectorHexDump (const std::vector< uint8_t > &bytes, const std::string &delimiter=":")
 Creates a string of hex digit pairs from a vector of bytes.
 

Detailed Description

LegalLogMgr abstract class.

Definition at line 39 of file legal_log_mgr.h.

Constructor & Destructor Documentation

◆ LegalLogMgr()

isc::dhcp::LegalLogMgr::LegalLogMgr ( const isc::db::DatabaseConnection::ParameterMap parameters)
inline

Constructor.

Definition at line 42 of file legal_log_mgr.h.

◆ ~LegalLogMgr()

virtual isc::dhcp::LegalLogMgr::~LegalLogMgr ( )
virtualdefault

Destructor.

Derived destructors do call the close method.

Member Function Documentation

◆ close()

virtual void isc::dhcp::LegalLogMgr::close ( )
pure virtual

Closes the store.

◆ currentTimeInfo()

struct tm isc::dhcp::LegalLogMgr::currentTimeInfo ( ) const
virtual

Returns the current local date and time.

This is exposed primarily to simplify testing.

Definition at line 183 of file legal_log_mgr.cc.

◆ genDurationString()

string isc::dhcp::LegalLogMgr::genDurationString ( const uint32_t secs)
static

Translates seconds into a text string of days, hours, minutes and seconds.

The output string will have the following format:

"{<d> day(s) }<h> hrs <m> min <s> secs" Examples:

0 hrs 0 min 30 secs 2 hrs 11 min 50 secs 1 day 1 hrs 0 min 0 secs 60 days 0 hrs 0 min 10 secs
Parameters
secsNumber of seconds to convert
Returns
String containing the duration text

Definition at line 251 of file legal_log_mgr.cc.

◆ getNowString() [1/2]

string isc::dhcp::LegalLogMgr::getNowString ( ) const
virtual

Returns the current date and time as string.

Returns the current local date and time as a string. The date and time is formatted according to the hook's timestamp_format parameter, or "%Y-%m-%d %H:%M:%S %Z" by default if not configured otherwise. The maximum length of the result is 128 bytes.

Returns
std::string containing the formatted current date and time.
Exceptions
LegalLogMgrErrorif the result string is larger than 128 bytes.

Definition at line 198 of file legal_log_mgr.cc.

References getNowString().

Referenced by getNowString().

+ Here is the call graph for this function:

◆ getNowString() [2/2]

string isc::dhcp::LegalLogMgr::getNowString ( const std::string & format) const
virtual

Returns the current date and time as a string using a specific strftime format string.

Returns the current local date and time as a string based on the given format. Maximum length of the result is 128 bytes.

Parameters
formatDesired format for the string. Permissible formatting is that supported by strftime plus the 'Q' extra format which adds the microseconds subunits. The default is: "%Y-%m-%d %H:%M:%S %Z".
Returns
std::string containing the formatted current date and time.
Exceptions
LegalLogMgrErrorif the result string is larger than 128 bytes.

Definition at line 204 of file legal_log_mgr.cc.

References getTimeString(), and now().

+ Here is the call graph for this function:

◆ getParameters()

virtual isc::db::DatabaseConnection::ParameterMap isc::dhcp::LegalLogMgr::getParameters ( ) const
inlinevirtual

Return backend parameters.

Returns the backend parameters

Returns
Parameters of the backend.

Definition at line 233 of file legal_log_mgr.h.

◆ getRequestFormatExpression()

isc::dhcp::ExpressionPtr isc::dhcp::LegalLogMgr::getRequestFormatExpression ( )
inline

Gets request extended format expression for custom logging.

Returns
The request extended format expression.

Definition at line 196 of file legal_log_mgr.h.

◆ getResponseFormatExpression()

isc::dhcp::ExpressionPtr isc::dhcp::LegalLogMgr::getResponseFormatExpression ( )
inline

Gets response extended format expression for custom logging.

Returns
The response extended format expression.

Definition at line 208 of file legal_log_mgr.h.

◆ getTimestampFormat()

std::string isc::dhcp::LegalLogMgr::getTimestampFormat ( )
inline

Gets the timestamp format used for logging.

Returns
The format for the string. Permissible formatting is the one supported by strftime plus the 'Q' extra format which adds the microseconds subunits.

Definition at line 224 of file legal_log_mgr.h.

◆ getTimeString()

string isc::dhcp::LegalLogMgr::getTimeString ( const struct timespec & time,
const std::string & format )
static

Returns a time as string.

Returns the time as a string based on the given format. Maximum length of the result is 128 bytes.

Parameters
timeTime to format.
formatDesired format for the string. Permissible formatting is that supported by strftime plus the 'Q' extra format which adds the microseconds subunits. The default is: "%Y-%m-%d %H:%M:%S %Z".
Returns
std::string containing the formatted current date and time
Exceptions
LegalLogMgrErrorif the result string is larger than 128 bytes.

Definition at line 210 of file legal_log_mgr.cc.

References isc_throw.

Referenced by getNowString().

◆ getType()

virtual std::string isc::dhcp::LegalLogMgr::getType ( ) const
pure virtual

Return backend type.

Returns the type of the backend (e.g. "mysql", "logfile" etc.)

Returns
Type of the backend.

◆ isUnusable()

virtual bool isc::dhcp::LegalLogMgr::isUnusable ( )
inlinevirtual

Flag which indicates if the forensic log backend has at least one unusable connection.

Returns
true if there is at least one unusable connection, false otherwise

Definition at line 251 of file legal_log_mgr.h.

◆ now()

struct timespec isc::dhcp::LegalLogMgr::now ( ) const
virtual

Returns the current system time.

This is exposed primarily to simplify testing.

Definition at line 191 of file legal_log_mgr.cc.

Referenced by getNowString().

◆ open()

virtual void isc::dhcp::LegalLogMgr::open ( )
pure virtual

Opens the store.

◆ parseConfig()

void isc::dhcp::LegalLogMgr::parseConfig ( const isc::data::ConstElementPtr & parameters,
isc::db::DatabaseConnection::ParameterMap & map )
static

Parse database specification.

Parse the configuration and check that the various keywords are consistent.

Parameters
parametersThe library parameters.
mapThe parameter map used by LegalLogMgr objects.

Definition at line 37 of file legal_log_mgr.cc.

References parseDatabase(), parseExtraParameters(), and parseFile().

+ Here is the call graph for this function:

◆ parseDatabase()

void isc::dhcp::LegalLogMgr::parseDatabase ( const isc::data::ConstElementPtr & parameters,
isc::db::DatabaseConnection::ParameterMap & map )
static

Parse database specification.

Code adapted from isc::dhcp::DbAccessParser::parse

Parse the configuration and check that the various keywords are consistent.

Parameters
parametersThe library parameters.
mapThe parameter map used by LegalLogMgr objects.

Definition at line 48 of file legal_log_mgr.cc.

References isc_throw, isc::util::ReconnectCtl::onFailActionFromText(), isc::util::ReconnectCtl::onFailActionToText(), and isc::db::DatabaseConnection::redactedAccessString().

Referenced by parseConfig().

+ Here is the call graph for this function:

◆ parseExtraParameters()

void isc::dhcp::LegalLogMgr::parseExtraParameters ( const isc::data::ConstElementPtr & parameters,
isc::db::DatabaseConnection::ParameterMap & map )
static

Parse extra parameters which are not related to backend connection.

Parameters
parametersThe library parameters.

Definition at line 168 of file legal_log_mgr.cc.

Referenced by parseConfig().

◆ parseFile()

void isc::dhcp::LegalLogMgr::parseFile ( const isc::data::ConstElementPtr & parameters,
isc::db::DatabaseConnection::ParameterMap & map )
static

Parse file specification.

Parse the configuration and check that the various keywords are consistent.

Parameters
parametersThe library parameters.

Definition at line 132 of file legal_log_mgr.cc.

References isc_throw.

Referenced by parseConfig().

◆ setParameters()

virtual void isc::dhcp::LegalLogMgr::setParameters ( isc::db::DatabaseConnection::ParameterMap parameters)
inlinevirtual

Sets backend parameters.

Sets the backend parameters

Parameters
parameterParameters of the backend.

Definition at line 242 of file legal_log_mgr.h.

◆ setRequestFormatExpression()

void isc::dhcp::LegalLogMgr::setRequestFormatExpression ( const std::string & extended_format)

Sets request extended format expression for custom logging.

Parameters
extended_formatThe request extended format expression.

Definition at line 305 of file legal_log_mgr.cc.

References isc::eval::EvalContext::expression_, isc::dhcp::CfgMgr::instance(), isc::eval::EvalContext::PARSER_STRING, isc::eval::EvalContext::parseString(), isc::dhcp::Option::V4, and isc::dhcp::Option::V6.

+ Here is the call graph for this function:

◆ setResponseFormatExpression()

void isc::dhcp::LegalLogMgr::setResponseFormatExpression ( const std::string & extended_format)

Sets response extended format expression for custom logging.

Parameters
extended_formatThe response extended format expression.

Definition at line 318 of file legal_log_mgr.cc.

References isc::eval::EvalContext::expression_, isc::dhcp::CfgMgr::instance(), isc::eval::EvalContext::PARSER_STRING, isc::eval::EvalContext::parseString(), isc::dhcp::Option::V4, and isc::dhcp::Option::V6.

+ Here is the call graph for this function:

◆ setTimestampFormat()

void isc::dhcp::LegalLogMgr::setTimestampFormat ( const std::string & timestamp_format)

Sets the timestamp format used for logging.

Parameters
formatDesired format for the string. Permissible formatting is the one supported by strftime plus the 'Q' extra format which adds the microseconds subunits. The default is: "%Y-%m-%d %H:%M:%S %Z".

Definition at line 331 of file legal_log_mgr.cc.

◆ vectorDump()

string isc::dhcp::LegalLogMgr::vectorDump ( const std::vector< uint8_t > & bytes)
static

Creates a string from a vector of printable bytes.

This assumes that str::isPrintable was called and returned true.

Parameters
bytesVector of bytes to convert

Definition at line 297 of file legal_log_mgr.cc.

◆ vectorHexDump()

string isc::dhcp::LegalLogMgr::vectorHexDump ( const std::vector< uint8_t > & bytes,
const std::string & delimiter = ":" )
static

Creates a string of hex digit pairs from a vector of bytes.

Parameters
bytesVector of bytes to convert
delimiterString to use a delimiter, defaults to ":"
Returns
std::string containing the hex output

Definition at line 281 of file legal_log_mgr.cc.

◆ writeln()

virtual void isc::dhcp::LegalLogMgr::writeln ( const std::string & text,
const std::string & addr )
pure virtual

Appends a string to the store with a timestamp and address.

Parameters
textString to append
addrAddress or prefix
Exceptions
LegalLogMgrErrorif the write fails

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