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

A class to represent a logging mechanism. More...

#include <be_io_logsheet.h>

Inherits std::ostream.

Inherited by BiometricEvaluation::IO::FileLogsheet, and BiometricEvaluation::IO::SysLogsheet.

Public Types

enum class  Kind { Null , File , Syslog }
 

Public Member Functions

 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...
 

Static Public Member Functions

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

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...
 

Protected Member Functions

void incrementEntryNumber ()
 Increment the current entry number. More...
 
std::string getCurrentEntryNumberAsString () const
 Obtain the current entry 'tag', in 'Edddd' format. More...
 

Detailed Description

A class to represent a logging mechanism.

A Logsheet is an output stream, so applications can write into the stream as a staging area using the << operator, then start a new entry by calling newEntry(). Entries in the log are prefixed with an entry number, which is incremented when the entry is written (either by directly calling write(), or calling newEntry()).

How the log data is stored is implemented by subclasses of Logsheet.

Note
By default, the entries in the Logsheet may not be immediately written to the backing store, depending on the buffering behavior of the operating system. Applications can force a write by invoking sync(), or force a write at every new log entry by invoking setAutoSync(true).
Entries created by applications may be composed of more than one line (each separated by the newline character). The text at the beginning of a line should not "look like" an entry number:
Edddd
i.e. the entry delimiter followed by some digits. Logsheet won't check for that condition, but any existing Logsheet that is re-opened for append may have an incorrect starting entry number.

Definition at line 57 of file be_io_logsheet.h.

Member Enumeration Documentation

◆ Kind

Enumerator
Null 

No backing store log sheet.

File 

File-based log sheet.

Syslog 

Syslog daemon backing store.

Definition at line 60 of file be_io_logsheet.h.

Constructor & Destructor Documentation

◆ Logsheet()

BiometricEvaluation::IO::Logsheet::Logsheet ( )

Create a Logsheet that has no backing store.

A log entry is maintained, but cannot be permanently stored. This is the Null Logsheet.

◆ ~Logsheet()

virtual BiometricEvaluation::IO::Logsheet::~Logsheet ( )
virtual

Destructor.

Member Function Documentation

◆ getTypeFromURL()

static Logsheet::Kind BiometricEvaluation::IO::Logsheet::getTypeFromURL ( const std::string &  url)
static

Map the URL scheme, taken from a string containing the entire URL, into a Logsheet type.

Parameters
[in]urlThe unform resource locator of the Logsheet.
Returns
The type of Logsheet represented by the URL.
Exceptions
Error::ParameterErrorThe URL scheme is missing or invalid.

◆ lineIsEntry()

static bool BiometricEvaluation::IO::Logsheet::lineIsEntry ( const std::string &  line)
static

Helper function to determine whether a string is a valid log entry.

Parameters
[in]lineThe string potentially containing a log entry.
Returns
true if the string is a log entry, false otherwise.

◆ lineIsComment()

static bool BiometricEvaluation::IO::Logsheet::lineIsComment ( const std::string &  line)
static

Helper function to determine whether a string is a valid comment log entry.

Parameters
[in]lineThe string potentially containing a comment entry.
Returns
true if the string is a comment entry, false otherwise.

◆ lineIsDebug()

static bool BiometricEvaluation::IO::Logsheet::lineIsDebug ( const std::string &  line)
static

Helper function to determine whether a string is a valid debug log entry.

Parameters
[in]lineThe string potentially containing a debug entry.
Returns
true if the string is a debug entry, false otherwise.

◆ newEntry()

void BiometricEvaluation::IO::Logsheet::newEntry ( )

Start a new entry, causing the existing entry to be closed and written.

Applications do not have to call this method for the first entry, however, as the stream is ready for writing upon construction.

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

◆ getCurrentEntry()

std::string BiometricEvaluation::IO::Logsheet::getCurrentEntry ( ) const

Obtain the contents of the current entry currently under construction.

Returns
The text of the current entry.

◆ resetCurrentEntry()

void BiometricEvaluation::IO::Logsheet::resetCurrentEntry ( )

Reset the current entry buffer to the beginning.

◆ getCurrentEntryNumber()

uint32_t BiometricEvaluation::IO::Logsheet::getCurrentEntryNumber ( ) const

Obtain the current entry number.

Returns
The current entry number.

◆ write()

virtual void BiometricEvaluation::IO::Logsheet::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 in BiometricEvaluation::IO::FileLogsheet, and BiometricEvaluation::IO::SysLogsheet.

◆ writeComment()

virtual void BiometricEvaluation::IO::Logsheet::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 in BiometricEvaluation::IO::FileLogsheet, and BiometricEvaluation::IO::SysLogsheet.

◆ writeDebug()

virtual void BiometricEvaluation::IO::Logsheet::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 in BiometricEvaluation::IO::FileLogsheet, and BiometricEvaluation::IO::SysLogsheet.

◆ setCommit()

void BiometricEvaluation::IO::Logsheet::setCommit ( const bool  state)

Enable or disable the commitment of normal entries to the backing log storage.

When entry commitment is disabled, the entry number is not incremented. Entries may be streamed into the object, and new entries created.

Parameters
[in]stateTrue if normal entries are to be committed, false if not.

◆ getCommit()

bool BiometricEvaluation::IO::Logsheet::getCommit ( ) const

Get the current entry commit state.

Returns
true if normal entries are to be committed, false if not.

◆ setDebugCommit()

void BiometricEvaluation::IO::Logsheet::setDebugCommit ( const bool  state)

Enable or disable the commitment of debug entries to the backing log storage.

When debug entry commitment is disabled, calls to writeDebug may still be made, but those entries do not appear in the log backing store.

Parameters
[in]statetrue if debug entries are to be committed, false if not.

◆ getDebugCommit()

bool BiometricEvaluation::IO::Logsheet::getDebugCommit ( ) const

Get the current debug entry commit state.

Returns
true if debug entries are committed to the backing store, false otherwise.

◆ setCommentCommit()

void BiometricEvaluation::IO::Logsheet::setCommentCommit ( const bool  state)

Enable or disable the commitment of comment entries to the backing log storage.

When comment entry commitment is disabled, calls to writeComment may still be made, but those entries do not appear in the log backing store.

Parameters
[in]statetrue if comment entries are to be committed, false if not.

◆ getCommentCommit()

bool BiometricEvaluation::IO::Logsheet::getCommentCommit ( ) const

Get the current comment entry commit state.

Returns
true if comment entries are committed to the backing store, false otherwise.

◆ sync()

virtual void BiometricEvaluation::IO::Logsheet::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 in BiometricEvaluation::IO::FileLogsheet, and BiometricEvaluation::IO::SysLogsheet.

◆ setAutoSync()

void BiometricEvaluation::IO::Logsheet::setAutoSync ( bool  state)

Turn on/off auto-sync of the data.

Applications may gain performance by turning off auto-sync, or gain reliability by turning it on.

Parameters
stateWhen true, the data is sync'd whenever newEntry() is or write() is called. When false, sync() must be called to force a write.

◆ getAutoSync()

bool BiometricEvaluation::IO::Logsheet::getAutoSync ( ) const

Return the current auto-sync state.

Returns
true if auto-sync is on, false otherwise.

◆ trim()

static std::string BiometricEvaluation::IO::Logsheet::trim ( const std::string &  entry)
static

Trim delimiters from Logsheet entries.

Works for comments and numbered entries.

Parameters
[in]entryThe entry to trim.
Returns
Delimiter-less entry.

◆ incrementEntryNumber()

void BiometricEvaluation::IO::Logsheet::incrementEntryNumber ( )
protected

Increment the current entry number.

◆ getCurrentEntryNumberAsString()

std::string BiometricEvaluation::IO::Logsheet::getCurrentEntryNumberAsString ( ) const
protected

Obtain the current entry 'tag', in 'Edddd' format.

Returns
The text of the current entry tag.

Member Data Documentation

◆ CommentDelimiter

const char BiometricEvaluation::IO::Logsheet::CommentDelimiter = '#'
static

Delimiter for a comment line in the log sheet.

Definition at line 70 of file be_io_logsheet.h.

◆ EntryDelimiter

const char BiometricEvaluation::IO::Logsheet::EntryDelimiter = 'E'
static

Delimiter for an entry line in the log sheet.

Definition at line 73 of file be_io_logsheet.h.

◆ DebugDelimiter

const char BiometricEvaluation::IO::Logsheet::DebugDelimiter = 'D'
static

Delimiter for an debug line in the log sheet.

Definition at line 76 of file be_io_logsheet.h.

◆ DescriptionTag

const std::string BiometricEvaluation::IO::Logsheet::DescriptionTag
static

The tag for the description string.

Definition at line 79 of file be_io_logsheet.h.

◆ FILEURLSCHEME

const std::string BiometricEvaluation::IO::Logsheet::FILEURLSCHEME
static

The URL scheme to be used for FileLogsheet URL strings.

Definition at line 85 of file be_io_logsheet.h.

◆ SYSLOGURLSCHEME

const std::string BiometricEvaluation::IO::Logsheet::SYSLOGURLSCHEME
static

The URL scheme to be used for SysLogsheet URL strings.

Definition at line 91 of file be_io_logsheet.h.


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