Web Analytics Made Easy - Statcounter
Skip to content

Class SBCLogEvent#

ClassList > 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:

  • eventType The type of the log event.
  • filename The source file name where the event originated.
  • functionName The name of the function where the event originated.
  • line The line number in the source file where the event originated.
  • descriptionMessage A description message describing the event.
  • uuid The UUID of the library where the event is recorded.

function SBCLogEvent [2/2]#

Default constructor.

SBCLogEvent::SBCLogEvent () 

Constructs an empty SBCLogEvent with default values.

Initializes an empty SBCLogEvent with default values.


function getDescriptionMessage#

Returns message that describe the event.

const std::string & SBCLogEvent::getDescriptionMessage () 

Retrieves the description message of the event.

Returns:

The description message as a string.


function getFileLine#

Returns line number where event is recorded.

const std::string & SBCLogEvent::getFileLine () 

Retrieves the line number where the event was recorded.

Returns:

The line number as a string.


function getFilename#

Returns fileName where event is recorded.

const std::string & SBCLogEvent::getFilename () 

Retrieves the filename where the event was recorded.

Returns:

The filename as a string.


function getFunctionName#

Returns function name where event is recorded.

const std::string & SBCLogEvent::getFunctionName () 

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.

const std::string & SBCLogEvent::getLibraryUUID () 

Retrieves the UUID of the library where the event was recorded.

Returns:

The library UUID as a string.


function getTime#

Returns event date.

const std::string & SBCLogEvent::getTime () 

Retrieves the event time.

Returns:

The event time as a string.


function getType#

Returns event type.

Type SBCLogEvent::getType () 

Retrieves the type of the event.

Returns:

The event type.


function hash#

Returns the hash of the event.

size_t SBCLogEvent::hash () const

Computes a hash value for the event based on its properties.

Returns:

The computed hash value.


function isSerializable#

Returns true __

virtual bool SBCLogEvent::isSerializable () const

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:

  • serializer The serializer to write the event data to.
  • sdkVersionNumber The SDK version number (optional).

function setDescriptionMessage#

Sets a message describing the event.

void SBCLogEvent::setDescriptionMessage (
    const std::string & message
) 

Sets the description message of the event.

Parameters:

  • message The new description message.

function setFileLine#

Sets line number where event is recorded.

void SBCLogEvent::setFileLine (
    const std::string & line
) 

Sets the line number where the event was recorded.

Parameters:

  • line The new line number.

function setFilename#

Sets fileName where event is recorded.

void SBCLogEvent::setFilename (
    const std::string & name
) 

Sets the filename where the event was recorded.

Parameters:

  • filename The new filename.

function setFunctionName#

Sets function name where event is recorded.

void SBCLogEvent::setFunctionName (
    const std::string & name
) 

Sets the function name where the event was recorded.

Parameters:

  • name The new function name.

function setLibraryUUID#

Sets uuid of library where event is recorded.

void SBCLogEvent::setLibraryUUID (
    const std::string & name
) 

Sets the UUID of the library where the event was recorded.

Parameters:

  • uuid The new library UUID.

function setTime#

Sets event date.

void SBCLogEvent::setTime (
    const std::string & date
) 

Sets the event time.

Parameters:

  • date The new event time.

function setType#

Sets event type.

void SBCLogEvent::setType (
    Type level
) 

Sets the type of the event.

Parameters:

  • type The new event type.

function toString#

Formats the log event as a string.

std::string SBCLogEvent::toString (
    bool printTime=true,
    bool printLocation=true
) const

Generates a formatted string representation of the log event, optionally including the timestamp and source location.

Parameters:

  • printTime If true, includes the event time in the output. The time is formatted as YYYY-MM-D_HH-MM-SS-mmm.
  • printLocation If true, 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:

  • serializer The serializer to read the event data from.
  • sdkVersionNumber The SDK version number (optional).

function ~SBCLogEvent#

Destructor.

virtual SBCLogEvent::~SBCLogEvent () 

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 .

static std::string SBCLogEvent::getPublicTypeString (
    SBCLogEvent::Type e
) 

Returns the public string representation of a log event type.

Converts the specified log event type to its public string representation.

Parameters:

  • e The event type.

Returns:

The public string representation of the provided event type.


function getTypeFromString#

Returns the SBCLogEvent::Type from the given string.

static SBCLogEvent::Type SBCLogEvent::getTypeFromString (
    const std::string & typeString
) 

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:

  • typeString The 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 .

static std::string SBCLogEvent::getTypeString (
    SBCLogEvent::Type e
) 

Returns the string representation of a log event type.

Converts the specified log event type to its string representation.

Parameters:

  • e The event type.

Returns:

The string representation of the provided event type.


function hideFilePaths#

Hides the file path from the input for privacy.

static std::string SBCLogEvent::hideFilePaths (
    const std::string & input
) 

Masks file paths in the input string for privacy.

Parameters:

  • input The input string possibly containing file paths.

Returns:

The input string with file paths replaced by a placeholder.