Class SBCLogEventCollection#
ClassList > SBCLogEventCollection
LogEvent storage. More...
#include <SBCLogEventCollection.hpp>
Public Functions#
| Type | Name |
|---|---|
| SBCLogEventCollection (const std::string & filename) Constructs a log event collection and loads events from the specified file. |
|
| SBCLogEventCollection () Constructs an empty log event collection. |
|
| void | addEvent (SBCLogEvent::Type eventLevel, const std::string & filename, const std::string & functionName, const std::string & lineNumber, const std::string & descriptionMessage, const std::string & uuid) Creates a new log event with the specified details and adds it to the collection. |
| void | addEvent (SBCLogEvent * event) Adds an existing log event to the collection, avoiding duplicate events based on a hash. |
| void | display () Display method. |
| std::vector< SBCLogEvent * > * | getEvents () Returns event date. |
| void | load (const std::string & filename, bool binary=true) Load the logEvent collection. |
| void | reDisplay () Useful if one wants to display again after having changed display configuration. |
| void | reset () Clears all events from the collection and resets the display index. |
| void | save (const std::string & filename, bool binary=true) const Save the logEvent collection. |
| void | setDisplayConfig (bool printTime, bool printLocation) Configures the display options for events. |
| void | setEvents (std::vector< SBCLogEvent * > * vector) Sets event date. |
| virtual | ~SBCLogEventCollection () Destroys the log event collection and releases allocated resources. |
Detailed Description#
Every program needs to report/handle log conditions. This is done by managing an event stack where messages, with helpful runtime information, are put. A SBCLogEventCollection represent a logging event collection.
Public Functions Documentation#
function SBCLogEventCollection [1/2]#
Constructs a log event collection and loads events from the specified file.
Parameters:
filenamePath to the file from which to load the log events.
function SBCLogEventCollection [2/2]#
Constructs an empty log event collection.
function addEvent [1/2]#
Creates a new log event with the specified details and adds it to the collection.
void SBCLogEventCollection::addEvent (
SBCLogEvent::Type eventLevel,
const std::string & filename,
const std::string & functionName,
const std::string & lineNumber,
const std::string & descriptionMessage,
const std::string & uuid
)
Parameters:
eventLevelSeverity level of the log event.filenameName of the source file where the event originated.functionNameName of the function where the event originated.lineNumberLine number in the source file where the event originated.descriptionMessageDescriptive message for the event.uuidUnique identifier for the event.
function addEvent [2/2]#
Adds an existing log event to the collection, avoiding duplicate events based on a hash.
This function checks for an existing event with the same hash, tracks occurrence counts, and adds the event if appropriate.
Parameters:
eventPointer to the log event to add.
function display#
Display method.
Displays all events in the collection from the first undisplayed event onward.
This function iterates over the events starting at the current display index, prints each event using the configured display options, and updates the index to the end of the collection.
function getEvents#
Returns event date.
Retrieves the vector of log events stored in the collection.
Returns:
Pointer to the vector of log event pointers.
function load#
Load the logEvent collection.
Loads the log event collection from a file.
This function creates a serializer appropriate for the file format, reads the collection, and cleans up the serializer.
Parameters:
filenamePath to the file from which to load the collection.binaryIf true, loads from a binary file; otherwise, loads from an XML file.
function reDisplay#
Useful if one wants to display again after having changed display configuration.
Resets the display index and displays all events from the beginning.
function reset#
Clears all events from the collection and resets the display index.
This function deletes each event object, clears the internal event vector, and resets the display position to the beginning.
function save#
Save the logEvent collection.
Saves the log event collection to a file.
This function selects the appropriate serializer based on the binary flag, writes the collection to the specified file, and releases the serializer.
Parameters:
filenamePath to the file where the collection will be saved.binaryIf true, saves in binary format; otherwise, saves in XML format.
function setDisplayConfig#
Configures the display options for events.
Parameters:
printTimeIf true, event timestamps will be printed.printLocationIf true, file and line information will be printed.
function setEvents#
Sets event date.
Replaces the internal event vector with the provided vector.
Parameters:
vectorPointer to the new vector of log event pointers.
function ~SBCLogEventCollection#
Destroys the log event collection and releases allocated resources.