Class 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:
eventLevelSeverity level of the event.filenameSource file name where the event originated.functionNameFunction name where the event originated.lineNumberLine number where the event originated.descriptionMessageHuman-readable description of the event.uuidIdentifier for the source or component generating the event.
function addEvent [2/2]#
Adds the given SBCLogEvent object to the current log event collection.
Parameters:
eventPointer to the SBCLogEvent to add.
function createTimer#
Creates a new timer with the given name, resetting any existing timer data.
Parameters:
nameName of the timer to create.
function display#
Methods relative to event display.
Displays the current log events using the collection's display method.
Display method.
function getCurrentLogEventCollection#
Returns the SBCLogEventCollection where logging events are stored.
Retrieves the current log event collection.
Returns:
Pointer to the SBCLogEventCollection storing logged events.
function getRootDir#
Retrieves the currently configured root directory.
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:
nameName of the timer.filenameSource file name where the measurement is reported.functionNameName of the function where the measurement is reported.lineNumberLine number in the source file where the measurement is reported.thresholdSecondsLimitThreshold 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:
nameName of the timer.filenameSource file name where the measurement is reported.functionNameName of the function where the measurement is reported.lineNumberLine number in the source file where the measurement is reported.thresholdSecondsLimitThreshold 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:
nameName of the timer.filenameSource file name where the print is reported.functionNameName of the function where the print is reported.lineNumberLine number in the source file where the print is reported.thresholdSecondsLimitThreshold 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.
Redisplays the current log events, useful after modifying display settings.
function reset#
Clean up.
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.
Parameters:
nameName of the timer to reuse.
function save#
Saves the current log event collection to a timestamped file in the root directory.
The filename includes the current date and time.
function setupRootDir#
Sets the root directory for log file storage.
Parameters:
dirPath to the root directory.
Public Static Functions Documentation#
function getInstance#
Returns the unique instance of event manager.
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.