Web Analytics Made Easy - Statcounter
Skip to content

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.

explicit SBCLogEventCollection::SBCLogEventCollection (
    const std::string & filename
) 

Parameters:

  • filename Path to the file from which to load the log events.

function SBCLogEventCollection [2/2]#

Constructs an empty log event collection.

SBCLogEventCollection::SBCLogEventCollection () 


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:

  • eventLevel Severity level of the log event.
  • filename Name of the source file where the event originated.
  • functionName Name of the function where the event originated.
  • lineNumber Line number in the source file where the event originated.
  • descriptionMessage Descriptive message for the event.
  • uuid Unique identifier for the event.

function addEvent [2/2]#

Adds an existing log event to the collection, avoiding duplicate events based on a hash.

void SBCLogEventCollection::addEvent (
    SBCLogEvent * event
) 

This function checks for an existing event with the same hash, tracks occurrence counts, and adds the event if appropriate.

Parameters:

  • event Pointer to the log event to add.

function display#

Display method.

void SBCLogEventCollection::display () 

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.

std::vector< SBCLogEvent * > * SBCLogEventCollection::getEvents () 

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.

void SBCLogEventCollection::load (
    const std::string & filename,
    bool binary=true
) 

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:

  • filename Path to the file from which to load the collection.
  • binary If 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.

void SBCLogEventCollection::reDisplay () 

Resets the display index and displays all events from the beginning.


function reset#

Clears all events from the collection and resets the display index.

void SBCLogEventCollection::reset () 

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.

void SBCLogEventCollection::save (
    const std::string & filename,
    bool binary=true
) const

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:

  • filename Path to the file where the collection will be saved.
  • binary If true, saves in binary format; otherwise, saves in XML format.

function setDisplayConfig#

Configures the display options for events.

void SBCLogEventCollection::setDisplayConfig (
    bool printTime,
    bool printLocation
) 

Parameters:

  • printTime If true, event timestamps will be printed.
  • printLocation If true, file and line information will be printed.

function setEvents#

Sets event date.

void SBCLogEventCollection::setEvents (
    std::vector< SBCLogEvent * > * vector
) 

Replaces the internal event vector with the provided vector.

Parameters:

  • vector Pointer to the new vector of log event pointers.

function ~SBCLogEventCollection#

Destroys the log event collection and releases allocated resources.

virtual SBCLogEventCollection::~SBCLogEventCollection ()