NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BiometricEvaluation::IO::SysLogsheet Class Reference

A class to represent a single logging mechanism to a logging service on the network. More...

#include <be_io_syslogsheet.h>

Inherits BiometricEvaluation::IO::Logsheet.

Public Member Functions

 SysLogsheet (const std::string &url, const std::string &description, const std::string &appname, bool sequenced, bool utc)
 Create a new log sheet. More...
 
 SysLogsheet (const std::string &url, const std::string &description, const std::string &appname, const std::string &hostname, bool sequenced, bool utc)
 Create a new log sheet. More...
 
 ~SysLogsheet ()
 Destructor. More...
 
void write (const std::string &entry)
 Write a string as an entry to the backing store. More...
 
void writeComment (const std::string &entry)
 Write a string as a comment to the backing store. More...
 
void writeDebug (const std::string &entry)
 Write a string as a debug entry to the backing store. More...
 
void sync ()
 Synchronize any buffered data to the underlying backing store. More...
 
- Public Member Functions inherited from BiometricEvaluation::IO::Logsheet
 Logsheet ()
 Create a Logsheet that has no backing store. More...
 
virtual ~Logsheet ()
 Destructor. More...
 
void newEntry ()
 Start a new entry, causing the existing entry to be closed and written. More...
 
std::string getCurrentEntry () const
 Obtain the contents of the current entry currently under construction. More...
 
void resetCurrentEntry ()
 Reset the current entry buffer to the beginning. More...
 
uint32_t getCurrentEntryNumber () const
 Obtain the current entry number. More...
 
virtual void write (const std::string &entry)
 Write a string as an entry to the backing store. More...
 
virtual void writeComment (const std::string &entry)
 Write a string as a comment to the backing store. More...
 
virtual void writeDebug (const std::string &entry)
 Write a string as a debug entry to the backing store. More...
 
void setCommit (const bool state)
 Enable or disable the commitment of normal entries to the backing log storage. More...
 
bool getCommit () const
 Get the current entry commit state. More...
 
void setDebugCommit (const bool state)
 Enable or disable the commitment of debug entries to the backing log storage. More...
 
bool getDebugCommit () const
 Get the current debug entry commit state. More...
 
void setCommentCommit (const bool state)
 Enable or disable the commitment of comment entries to the backing log storage. More...
 
bool getCommentCommit () const
 Get the current comment entry commit state. More...
 
virtual void sync ()
 Synchronize any buffered data to the underlying backing store. More...
 
void setAutoSync (bool state)
 Turn on/off auto-sync of the data. More...
 
bool getAutoSync () const
 Return the current auto-sync state. More...
 

Protected Member Functions

 SysLogsheet (const SysLogsheet &)
 Prevent copying of SysLogsheet objects. More...
 
SysLogsheetoperator= (const SysLogsheet &)
 Prevent copying of SysLogsheet objects. More...
 
void setup (const std::string &url, const std::string &description)
 Helper function to build connections. More...
 
void writeToLogger (const std::string &priority, const char delimiter, const std::string &prefix, const std::string &message)
 Helper function to write to the logger. More...
 
- Protected Member Functions inherited from BiometricEvaluation::IO::Logsheet
void incrementEntryNumber ()
 Increment the current entry number. More...
 
std::string getCurrentEntryNumberAsString () const
 Obtain the current entry 'tag', in 'Edddd' format. More...
 

Protected Attributes

std::string _hostname
 
std::string _appname
 
std::string _procid
 
int _sockFD
 Socket file descriptor for the logging system. More...
 
bool _sequenced
 Whether to include entry sequence numbers. More...
 
bool _operational
 Whether the sheet is operational. More...
 
bool _utc
 Whether time stamps are in UTC. More...
 

Additional Inherited Members

- Public Types inherited from BiometricEvaluation::IO::Logsheet
enum class  Kind { Null , File , Syslog }
 
- Static Public Member Functions inherited from BiometricEvaluation::IO::Logsheet
static Logsheet::Kind getTypeFromURL (const std::string &url)
 Map the URL scheme, taken from a string containing the entire URL, into a Logsheet type. More...
 
static bool lineIsEntry (const std::string &line)
 Helper function to determine whether a string is a valid log entry. More...
 
static bool lineIsComment (const std::string &line)
 Helper function to determine whether a string is a valid comment log entry. More...
 
static bool lineIsDebug (const std::string &line)
 Helper function to determine whether a string is a valid debug log entry. More...
 
static std::string trim (const std::string &entry)
 Trim delimiters from Logsheet entries. More...
 
- Static Public Attributes inherited from BiometricEvaluation::IO::Logsheet
static const char CommentDelimiter = '#'
 Delimiter for a comment line in the log sheet. More...
 
static const char EntryDelimiter = 'E'
 Delimiter for an entry line in the log sheet. More...
 
static const char DebugDelimiter = 'D'
 Delimiter for an debug line in the log sheet. More...
 
static const std::string DescriptionTag
 The tag for the description string. More...
 
static const std::string FILEURLSCHEME
 The URL scheme to be used for FileLogsheet URL strings. More...
 
static const std::string SYSLOGURLSCHEME
 The URL scheme to be used for SysLogsheet URL strings. More...
 

Detailed Description

A class to represent a single logging mechanism to a logging service on the network.

Log entries are sent to the logging server in RFC5424 format with a timestamp of the local system in UTC. Normal and comment entries are sent to the logger with a PRI field indicating the 'local0' facility and a severity of 'Informational'. Debug entries are sent with facility of 'local1' and severity 'Debug'. A basic syslog config file would contain these lines: local0.info /var/log/info.log local1.debug /var/log/debug.log

The hostname is added to each entry but may be overridden by constructing the object with a given hostname, including the RFC5424 NILVALUE character. The PROCID part of each log message will be filled in with the process ID. Multi-line messages are segmented and sent the to logger as separate entries with the same timestamp and sequence number.

Definition at line 45 of file be_io_syslogsheet.h.

Constructor & Destructor Documentation

◆ SysLogsheet() [1/3]

BiometricEvaluation::IO::SysLogsheet::SysLogsheet ( const std::string &  url,
const std::string &  description,
const std::string &  appname,
bool  sequenced,
bool  utc 
)

Create a new log sheet.

Parameters
[in]urlThe Uniform Resource Locator describing the logging service. Accepted forms are syslog://hostname:port
[in]descriptionThe text used to describe the sheet. This text is written into the log prior to any entries.
[in]appnameThe name of the application. This text is written into each log entry.
[in]sequencedTrue if each entry should include a sequence number, false if not.
[in]utcTrue if timestamps should be in Coordinated Universal Time (UTC), false for local time.
Exceptions
Error::StrategyErrorAn error occurred when connecting to the logging system, or URL is malformed.

◆ SysLogsheet() [2/3]

BiometricEvaluation::IO::SysLogsheet::SysLogsheet ( const std::string &  url,
const std::string &  description,
const std::string &  appname,
const std::string &  hostname,
bool  sequenced,
bool  utc 
)

Create a new log sheet.

Parameters
[in]urlThe Uniform Resource Locator describing the logging service. Accepted forms are syslog://hostname:port
[in]descriptionThe text used to describe the sheet. This text is written into the log prior to any entries.
[in]appnameThe name of the application. This text is written into each log entry.
[in]hostnameThe string to use as the hostname for all log entries.
[in]sequencedTrue if each entry should include a sequence number, false if not.
[in]utcTrue if timestamps should be in Coordinated Universal Time (UTC), false for local time.
Exceptions
Error::StrategyErrorAn error occurred when connecting to the logging system, or URL is malformed.

◆ ~SysLogsheet()

BiometricEvaluation::IO::SysLogsheet::~SysLogsheet ( )

Destructor.

◆ SysLogsheet() [3/3]

BiometricEvaluation::IO::SysLogsheet::SysLogsheet ( const SysLogsheet )
protected

Prevent copying of SysLogsheet objects.

Member Function Documentation

◆ write()

void BiometricEvaluation::IO::SysLogsheet::write ( const std::string &  entry)
virtual

Write a string as an entry to the backing store.

This does not affect the current log entry buffer, but does increment the entry number.

Parameters
[in]entryThe text of the log entry.
Exceptions
Error::StrategyErrorAn error occurred when using the underlying backing store.

Reimplemented from BiometricEvaluation::IO::Logsheet.

◆ writeComment()

void BiometricEvaluation::IO::SysLogsheet::writeComment ( const std::string &  entry)
virtual

Write a string as a comment to the backing store.

This does not affect the current log entry buffer, and does not increment the entry number. A comment line is prefixed with CommentDelimiter followed by a space by this method.

Parameters
[in]entryThe text of the comment.
Exceptions
Error::StrategyErrorAn error occurred when using the underlying backing store.

Reimplemented from BiometricEvaluation::IO::Logsheet.

◆ writeDebug()

void BiometricEvaluation::IO::SysLogsheet::writeDebug ( const std::string &  entry)
virtual

Write a string as a debug entry to the backing store.

This does not affect the current log entry buffer, and does not increment the entry number. A debug line is prefixed with DebugDelimiter followed by a space.

Parameters
[in]entryThe text of the debug message.
Exceptions
Error::StrategyErrorAn error occurred when logging.

Reimplemented from BiometricEvaluation::IO::Logsheet.

◆ sync()

void BiometricEvaluation::IO::SysLogsheet::sync ( )
virtual

Synchronize any buffered data to the underlying backing store.

This syncing is dependent on the behavior of the underlying storage mechanism.

Exceptions
Error::StrategyErrorAn error occurred when using the underlying backing store.

Reimplemented from BiometricEvaluation::IO::Logsheet.

◆ operator=()

SysLogsheet & BiometricEvaluation::IO::SysLogsheet::operator= ( const SysLogsheet )
protected

Prevent copying of SysLogsheet objects.

◆ setup()

void BiometricEvaluation::IO::SysLogsheet::setup ( const std::string &  url,
const std::string &  description 
)
protected

Helper function to build connections.

◆ writeToLogger()

void BiometricEvaluation::IO::SysLogsheet::writeToLogger ( const std::string &  priority,
const char  delimiter,
const std::string &  prefix,
const std::string &  message 
)
protected

Helper function to write to the logger.

Member Data Documentation

◆ _hostname

std::string BiometricEvaluation::IO::SysLogsheet::_hostname
protected

Definition at line 148 of file be_io_syslogsheet.h.

◆ _appname

std::string BiometricEvaluation::IO::SysLogsheet::_appname
protected

Definition at line 149 of file be_io_syslogsheet.h.

◆ _procid

std::string BiometricEvaluation::IO::SysLogsheet::_procid
protected

Definition at line 150 of file be_io_syslogsheet.h.

◆ _sockFD

int BiometricEvaluation::IO::SysLogsheet::_sockFD
protected

Socket file descriptor for the logging system.

Definition at line 153 of file be_io_syslogsheet.h.

◆ _sequenced

bool BiometricEvaluation::IO::SysLogsheet::_sequenced
protected

Whether to include entry sequence numbers.

Definition at line 156 of file be_io_syslogsheet.h.

◆ _operational

bool BiometricEvaluation::IO::SysLogsheet::_operational
protected

Whether the sheet is operational.

Definition at line 159 of file be_io_syslogsheet.h.

◆ _utc

bool BiometricEvaluation::IO::SysLogsheet::_utc
protected

Whether time stamps are in UTC.

Definition at line 162 of file be_io_syslogsheet.h.


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