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 ×tamp_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 ¶meters, isc::db::DatabaseConnection::ParameterMap &map) |
Parse database specification. | |
static void | parseDatabase (const isc::data::ConstElementPtr ¶meters, isc::db::DatabaseConnection::ParameterMap &map) |
Parse database specification. | |
static void | parseExtraParameters (const isc::data::ConstElementPtr ¶meters, isc::db::DatabaseConnection::ParameterMap &map) |
Parse extra parameters which are not related to backend connection. | |
static void | parseFile (const isc::data::ConstElementPtr ¶meters, 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. | |
LegalLogMgr abstract class.
Definition at line 39 of file legal_log_mgr.h.
|
inline |
Constructor.
Definition at line 42 of file legal_log_mgr.h.
|
virtualdefault |
Destructor.
Derived destructors do call the close method.
|
pure virtual |
Closes the store.
|
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.
|
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
secs | Number of seconds to convert |
Definition at line 251 of file legal_log_mgr.cc.
|
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.
LegalLogMgrError | if the result string is larger than 128 bytes. |
Definition at line 198 of file legal_log_mgr.cc.
References getNowString().
Referenced by getNowString().
|
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.
format | Desired 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". |
LegalLogMgrError | if the result string is larger than 128 bytes. |
Definition at line 204 of file legal_log_mgr.cc.
References getTimeString(), and now().
|
inlinevirtual |
Return backend parameters.
Returns the backend parameters
Definition at line 233 of file legal_log_mgr.h.
|
inline |
Gets request extended format expression for custom logging.
Definition at line 196 of file legal_log_mgr.h.
|
inline |
Gets response extended format expression for custom logging.
Definition at line 208 of file legal_log_mgr.h.
|
inline |
Gets the timestamp format used for logging.
Definition at line 224 of file legal_log_mgr.h.
|
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.
time | Time to format. |
format | Desired 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". |
LegalLogMgrError | if the result string is larger than 128 bytes. |
Definition at line 210 of file legal_log_mgr.cc.
References isc_throw.
Referenced by getNowString().
|
pure virtual |
Return backend type.
Returns the type of the backend (e.g. "mysql", "logfile" etc.)
|
inlinevirtual |
Flag which indicates if the forensic log backend has at least one unusable connection.
Definition at line 251 of file legal_log_mgr.h.
|
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().
|
pure virtual |
Opens the store.
|
static |
Parse database specification.
Parse the configuration and check that the various keywords are consistent.
parameters | The library parameters. |
map | The parameter map used by LegalLogMgr objects. |
Definition at line 37 of file legal_log_mgr.cc.
References parseDatabase(), parseExtraParameters(), and parseFile().
|
static |
Parse database specification.
Code adapted from isc::dhcp::DbAccessParser::parse
Parse the configuration and check that the various keywords are consistent.
parameters | The library parameters. |
map | The 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().
|
static |
Parse extra parameters which are not related to backend connection.
parameters | The library parameters. |
Definition at line 168 of file legal_log_mgr.cc.
Referenced by parseConfig().
|
static |
Parse file specification.
Parse the configuration and check that the various keywords are consistent.
parameters | The library parameters. |
Definition at line 132 of file legal_log_mgr.cc.
References isc_throw.
Referenced by parseConfig().
|
inlinevirtual |
Sets backend parameters.
Sets the backend parameters
parameter | Parameters of the backend. |
Definition at line 242 of file legal_log_mgr.h.
void isc::dhcp::LegalLogMgr::setRequestFormatExpression | ( | const std::string & | extended_format | ) |
Sets request extended format expression for custom logging.
extended_format | The 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.
void isc::dhcp::LegalLogMgr::setResponseFormatExpression | ( | const std::string & | extended_format | ) |
Sets response extended format expression for custom logging.
extended_format | The 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.
void isc::dhcp::LegalLogMgr::setTimestampFormat | ( | const std::string & | timestamp_format | ) |
Sets the timestamp format used for logging.
format | Desired 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.
|
static |
Creates a string from a vector of printable bytes.
This assumes that str::isPrintable was called and returned true.
bytes | Vector of bytes to convert |
Definition at line 297 of file legal_log_mgr.cc.
|
static |
Creates a string of hex digit pairs from a vector of bytes.
bytes | Vector of bytes to convert |
delimiter | String to use a delimiter, defaults to ":" |
Definition at line 281 of file legal_log_mgr.cc.
|
pure virtual |
Appends a string to the store with a timestamp and address.
text | String to append |
addr | Address or prefix |
LegalLogMgrError | if the write fails |