Web Analytics Made Easy - Statcounter
Skip to content

Class SBCLogManager#

ClassList > SBCLogManager

The class SBCLogManager is dedicated to logging events handling.

  • #include <SBCLogManager.hpp>

Public Functions#

Type Name
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)
Method formatting and storing event raw data.
void addEvent (SBCLogEvent * event)
Adds the given SBCLogEvent object to the current log event collection.
void createTimer (const std::string & name)
Creates a new timer with the given name, resetting any existing timer data.
void display ()
Methods relative to event display.
SBCLogEventCollection * getCurrentLogEventCollection ()
Returns the SBCLogEventCollection where logging events are stored.
std::string getRootDir ()
Retrieves the currently configured root directory.
void measurePrintTimer (const std::string & name, const std::string & filename, const std::string & functionName, const std::string & lineNumber, double thresholdSeconds=5)
Measures the elapsed time since the timer named 'name' was started, prints a warning and logs an event if the duration exceeds the specified threshold.
void measurePrintTotalTimer (const std::string & name, const std::string & filename, const std::string & functionName, const std::string & lineNumber, double thresholdSeconds=5)
Measures the elapsed time since the timer named 'name' was started, updates the total elapsed time for the timer, and logs a warning if either the current or total duration exceeds the specified threshold.
void printTimer (const std::string & name, const std::string & filename, const std::string & functionName, const std::string & lineNumber, double thresholdSeconds=5)
Prints the elapsed time for the timer named 'name' and logs an event if it exceeds the given threshold.
void reDisplay ()
Useful if one wants to display again after having changed display configuration.
void reset ()
Clean up.
void reuseTimer (const std::string & name)
Reuses an existing timer identified by name, resetting its start time to the current time.
void save ()
Saves the current log event collection to a timestamped file in the root directory.
void setupRootDir (const std::string & rootDir)
Sets the root directory for log file storage.

Public Static Functions#

Type Name
SBCLogManager & getInstance ()
Returns the unique instance of event manager.

Public Functions Documentation#

function addEvent [1/2]#

Method formatting and storing event raw data.

void SBCLogManager::addEvent (
    SBCLogEvent::Type eventLevel,
    const std::string & filename,
    const std::string & functionName,
    const std::string & lineNumber,
    const std::string & descriptionMessage,
    const std::string & uuid
) 

Adds a new log event with the specified details to the current log event collection.

Parameters:

  • eventLevel Severity level of the event.
  • filename Source file name where the event originated.
  • functionName Function name where the event originated.
  • lineNumber Line number where the event originated.
  • descriptionMessage Human-readable description of the event.
  • uuid Identifier for the source or component generating the event.

function addEvent [2/2]#

Adds the given SBCLogEvent object to the current log event collection.

void SBCLogManager::addEvent (
    SBCLogEvent * event
) 

Parameters:


function createTimer#

Creates a new timer with the given name, resetting any existing timer data.

void SBCLogManager::createTimer (
    const std::string & name
) 

Parameters:

  • name Name of the timer to create.

function display#

Methods relative to event display.

void SBCLogManager::display () 

Displays the current log events using the collection's display method.

Display method.


function getCurrentLogEventCollection#

Returns the SBCLogEventCollection where logging events are stored.

SBCLogEventCollection * SBCLogManager::getCurrentLogEventCollection () 

Retrieves the current log event collection.

Returns:

Pointer to the SBCLogEventCollection storing logged events.


function getRootDir#

Retrieves the currently configured root directory.

std::string SBCLogManager::getRootDir () 

Returns:

String containing the root directory path.


function measurePrintTimer#

Measures the elapsed time since the timer named 'name' was started, prints a warning and logs an event if the duration exceeds the specified threshold.

void SBCLogManager::measurePrintTimer (
    const std::string & name,
    const std::string & filename,
    const std::string & functionName,
    const std::string & lineNumber,
    double thresholdSeconds=5
) 

This function measures the elapsed time for the named timer, updates internal timing data, and logs a warning event if the elapsed time exceeds the specified threshold.

Parameters:

  • name Name of the timer.
  • filename Source file name where the measurement is reported.
  • functionName Name of the function where the measurement is reported.
  • lineNumber Line number in the source file where the measurement is reported.
  • thresholdSecondsLimit Threshold in seconds; a warning is logged if the elapsed time exceeds this value divided by TIMING_TRESHOLD_DIVIDER.

function measurePrintTotalTimer#

Measures the elapsed time since the timer named 'name' was started, updates the total elapsed time for the timer, and logs a warning if either the current or total duration exceeds the specified threshold.

void SBCLogManager::measurePrintTotalTimer (
    const std::string & name,
    const std::string & filename,
    const std::string & functionName,
    const std::string & lineNumber,
    double thresholdSeconds=5
) 

This function measures the elapsed time for the named timer, updates the cumulative elapsed time, and logs a warning event if the current or total duration exceeds the given threshold.

Parameters:

  • name Name of the timer.
  • filename Source file name where the measurement is reported.
  • functionName Name of the function where the measurement is reported.
  • lineNumber Line number in the source file where the measurement is reported.
  • thresholdSecondsLimit Threshold in seconds; a warning is logged if the elapsed time or total time exceeds this value divided by TIMING_TRESHOLD_DIVIDER.

function printTimer#

Prints the elapsed time for the timer named 'name' and logs an event if it exceeds the given threshold.

void SBCLogManager::printTimer (
    const std::string & name,
    const std::string & filename,
    const std::string & functionName,
    const std::string & lineNumber,
    double thresholdSeconds=5
) 

If a total elapsed time exists, both current and total durations are reported.

Parameters:

  • name Name of the timer.
  • filename Source file name where the print is reported.
  • functionName Name of the function where the print is reported.
  • lineNumber Line number in the source file where the print is reported.
  • thresholdSecondsLimit Threshold in seconds; a warning is logged if the elapsed time or total time exceeds this value divided by TIMING_TRESHOLD_DIVIDER.

function reDisplay#

Useful if one wants to display again after having changed display configuration.

void SBCLogManager::reDisplay () 

Redisplays the current log events, useful after modifying display settings.


function reset#

Clean up.

void SBCLogManager::reset () 

Resets the current log event collection, clearing all stored events.


function reuseTimer#

Reuses an existing timer identified by name, resetting its start time to the current time.

void SBCLogManager::reuseTimer (
    const std::string & name
) 

Parameters:

  • name Name of the timer to reuse.

function save#

Saves the current log event collection to a timestamped file in the root directory.

void SBCLogManager::save () 

The filename includes the current date and time.


function setupRootDir#

Sets the root directory for log file storage.

void SBCLogManager::setupRootDir (
    const std::string & rootDir
) 

Parameters:

  • dir Path to the root directory.

Public Static Functions Documentation#

function getInstance#

Returns the unique instance of event manager.

static SBCLogManager & SBCLogManager::getInstance () 

Returns the unique instance of the SBCLogManager singleton.

This function returns the singleton instance, creating it on first use if it does not already exist.

Returns:

Reference to the singleton instance.