Class SBCLogEvent#
Log handling. More...
#include <SBCLogEvent.hpp>
Public Types#
| Type | Name |
|---|---|
| enum | Type Available log event types. |
Public Functions#
| Type | Name |
|---|---|
| SBCLogEvent (SBCLogEvent::Type eventLevel, const std::string & filename, const std::string & functionName, const std::string & lineNumber, const std::string & descriptionMessage, const std::string & uuid="BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB") Constructor. |
|
| SBCLogEvent () Default constructor. |
|
| const std::string & | getDescriptionMessage () Returns message that describe the event. |
| const std::string & | getFileLine () Returns line number where event is recorded. |
| const std::string & | getFilename () Returns fileName where event is recorded. |
| const std::string & | getFunctionName () Returns function name where event is recorded. |
| const std::string & | getLibraryUUID () Returns uuid of library where event is recorded. |
| const std::string & | getTime () Returns event date. |
| Type | getType () Returns event type. |
| size_t | hash () const Returns the hash of the event. |
| virtual bool | isSerializable () const Returns true __ |
| virtual void | serialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER) const Serializes the logEvent. |
| void | setDescriptionMessage (const std::string & message) Sets a message describing the event. |
| void | setFileLine (const std::string & line) Sets line number where event is recorded. |
| void | setFilename (const std::string & name) Sets fileName where event is recorded. |
| void | setFunctionName (const std::string & name) Sets function name where event is recorded. |
| void | setLibraryUUID (const std::string & name) Sets uuid of library where event is recorded. |
| void | setTime (const std::string & date) Sets event date. |
| void | setType (Type level) Sets event type. |
| std::string | toString (bool printTime=true, bool printLocation=true) const Formats the log event as a string. |
| virtual void | unserialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER) Unserializes the logEvent. |
| virtual | ~SBCLogEvent () Destructor. |
Public Static Functions#
| Type | Name |
|---|---|
| std::string | getPublicTypeString (SBCLogEvent::Type e) Returns the public string representation of the given SBCLogEvent::Type . |
| SBCLogEvent::Type | getTypeFromString (const std::string & typeString) Returns the SBCLogEvent::Type from the given string. |
| std::string | getTypeString (SBCLogEvent::Type e) Returns the string representation of the given SBCLogEvent::Type . |
| std::string | hideFilePaths (const std::string & input) Hides the file path from the input for privacy. |
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 SBCLogEvent represent a logging event. An event is made up a date, a location (File / Line), a level and a description message
Public Types Documentation#
enum Type#
Available log event types.
enum SBCLogEvent::Type {
Analytics = 5,
StackHistory = 4,
Trace = 3,
Information = 2,
Warning = 1,
Error = 0
};
Public Functions Documentation#
function SBCLogEvent [1/2]#
Constructor.
SBCLogEvent::SBCLogEvent (
SBCLogEvent::Type eventLevel,
const std::string & filename,
const std::string & functionName,
const std::string & lineNumber,
const std::string & descriptionMessage,
const std::string & uuid="BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB"
)
Constructs an SBCLogEvent with specified details.
Initializes a new SBCLogEvent instance with the provided details.
Parameters:
eventTypeThe type of the log event.filenameThe source file name where the event originated.functionNameThe name of the function where the event originated.lineThe line number in the source file where the event originated.descriptionMessageA description message describing the event.uuidThe UUID of the library where the event is recorded.
function SBCLogEvent [2/2]#
Default constructor.
Constructs an empty SBCLogEvent with default values.
Initializes an empty SBCLogEvent with default values.
function getDescriptionMessage#
Returns message that describe the event.
Retrieves the description message of the event.
Returns:
The description message as a string.
function getFileLine#
Returns line number where event is recorded.
Retrieves the line number where the event was recorded.
Returns:
The line number as a string.
function getFilename#
Returns fileName where event is recorded.
Retrieves the filename where the event was recorded.
Returns:
The filename as a string.
function getFunctionName#
Returns function name where event is recorded.
Retrieves the function name where the event was recorded.
Returns:
The function name as a string.
function getLibraryUUID#
Returns uuid of library where event is recorded.
Retrieves the UUID of the library where the event was recorded.
Returns:
The library UUID as a string.
function getTime#
Returns event date.
Retrieves the event time.
Returns:
The event time as a string.
function getType#
Returns event type.
Retrieves the type of the event.
Returns:
The event type.
function hash#
Returns the hash of the event.
Computes a hash value for the event based on its properties.
Returns:
The computed hash value.
function isSerializable#
Returns true __
Indicates whether the event is serializable.
Returns:
true if the event can be serialized, false otherwise.
function serialize#
Serializes the logEvent.
virtual void SBCLogEvent::serialize (
SBCSerializer * serializer,
const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER
) const
Serializes the event to the given serializer.
Writes the log event data to the provided serializer.
Parameters:
serializerThe serializer to write the event data to.sdkVersionNumberThe SDK version number (optional).
function setDescriptionMessage#
Sets a message describing the event.
Sets the description message of the event.
Parameters:
messageThe new description message.
function setFileLine#
Sets line number where event is recorded.
Sets the line number where the event was recorded.
Parameters:
lineThe new line number.
function setFilename#
Sets fileName where event is recorded.
Sets the filename where the event was recorded.
Parameters:
filenameThe new filename.
function setFunctionName#
Sets function name where event is recorded.
Sets the function name where the event was recorded.
Parameters:
nameThe new function name.
function setLibraryUUID#
Sets uuid of library where event is recorded.
Sets the UUID of the library where the event was recorded.
Parameters:
uuidThe new library UUID.
function setTime#
Sets event date.
Sets the event time.
Parameters:
dateThe new event time.
function setType#
Sets event type.
Sets the type of the event.
Parameters:
typeThe new event type.
function toString#
Formats the log event as a string.
Generates a formatted string representation of the log event, optionally including the timestamp and source location.
Parameters:
printTimeIftrue, includes the event time in the output. The time is formatted as YYYY-MM-D_HH-MM-SS-mmm.printLocationIftrue, includes the file location in the output.
Returns:
A formatted string representing the log event.
function unserialize#
Unserializes the logEvent.
virtual void SBCLogEvent::unserialize (
SBCSerializer * serializer,
const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER
)
Deserializes the event from the given serializer.
Reads the log event data from the provided serializer.
Parameters:
serializerThe serializer to read the event data from.sdkVersionNumberThe SDK version number (optional).
function ~SBCLogEvent#
Destructor.
Destroys the SBCLogEvent and releases associated resources.
Cleans up the SBCLogEvent and releases allocated resources.
Public Static Functions Documentation#
function getPublicTypeString#
Returns the public string representation of the given SBCLogEvent::Type .
Returns the public string representation of a log event type.
Converts the specified log event type to its public string representation.
Parameters:
eThe event type.
Returns:
The public string representation of the provided event type.
function getTypeFromString#
Returns the SBCLogEvent::Type from the given string.
Parses a string to obtain the corresponding log event type.
Converts a string representation of a log event type back to the corresponding enum value.
Parameters:
typeStringThe string representation of the event type.
Returns:
The event type corresponding to the provided string.
function getTypeString#
Returns the string representation of the given SBCLogEvent::Type .
Returns the string representation of a log event type.
Converts the specified log event type to its string representation.
Parameters:
eThe event type.
Returns:
The string representation of the provided event type.
function hideFilePaths#
Hides the file path from the input for privacy.
Masks file paths in the input string for privacy.
Parameters:
inputThe input string possibly containing file paths.
Returns:
The input string with file paths replaced by a placeholder.