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.
|
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...
|
|
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.
◆ 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.
◆ 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 |
◆ 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] | url | The unform resource locator of the Logsheet. |
- Returns
- The type of Logsheet represented by the URL.
- Exceptions
-
◆ 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] | line | The 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] | line | The 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] | line | The 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
-
◆ 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 |
◆ 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] | entry | The text of the comment. |
- Exceptions
-
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] | entry | The text of the debug message. |
- Exceptions
-
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] | state | True 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] | state | true 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] | state | true 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 |
◆ 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
-
state | When 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] | entry | The 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.
◆ 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 |
◆ FILEURLSCHEME
const std::string BiometricEvaluation::IO::Logsheet::FILEURLSCHEME |
|
static |
◆ SYSLOGURLSCHEME
const std::string BiometricEvaluation::IO::Logsheet::SYSLOGURLSCHEME |
|
static |
The documentation for this class was generated from the following file: