Scene Fusion 2 API Reference
KS::Log Class Reference

#include <Log.h>

Public Member Functions

EXTERNAL void RegisterCallback (const std::string &channel, LogHandler handler, uint8_t levels, bool allowBubbling)
 
EXTERNAL void UnregisterCallback (const std::string &channel, LogHandler handler)
 
EXTERNAL void Write (const std::string &message, const std::string &channel, LogLevel level)
 

Static Public Member Functions

static EXTERNAL std::shared_ptr< LogInstance ()
 
static EXTERNAL void SetInstance (std::shared_ptr< Log > logPtr)
 
static EXTERNAL void Debug (const std::string &message, const std::string &channel="Root")
 
static EXTERNAL void Info (const std::string &message, const std::string &channel="Root")
 
static EXTERNAL void Warning (const std::string &message, const std::string &channel="Root")
 
static EXTERNAL void Error (const std::string &message, const std::string &channel="Root")
 
static EXTERNAL void Fatal (const std::string &message, const std::string &channel="Root")
 
static EXTERNAL std::string GetLevelString (LogLevel logLevel)
 
static EXTERNAL std::string GetTimeString ()
 

Detailed Description

Static logger class. Log messages have a level and a channel string that can be used to filter log messages. Channels can have parent channels. Any message a channel receives will also be sent to all of it's parent channels. Channels are seperated by ".", with children channel following parents. All channels are children of the root channel. Example: KS::Log::Info("X.Y", "This message will be received by channels 'X.Y', 'X', and 'Root');

Member Function Documentation

◆ Debug()

static EXTERNAL void KS::Log::Debug ( const std::string &  message,
const std::string &  channel = "Root" 
)
static

Write a DEBUG log message

Parameters
conststd::string& message to log
conststd::string& channel to log to

◆ Error()

static EXTERNAL void KS::Log::Error ( const std::string &  message,
const std::string &  channel = "Root" 
)
static

Write an ERROR log message

Parameters
conststd::string& message to log
conststd::string& channel to log to

◆ Fatal()

static EXTERNAL void KS::Log::Fatal ( const std::string &  message,
const std::string &  channel = "Root" 
)
static

Write a fatal log message

Parameters
conststd::string& message to log
conststd::string& channel to log to

◆ GetLevelString()

static EXTERNAL std::string KS::Log::GetLevelString ( LogLevel  logLevel)
static

Get text for a logging level

Parameters
LogLevellogLevel
Returns
std::string name of log level.

◆ GetTimeString()

static EXTERNAL std::string KS::Log::GetTimeString ( )
static

Get a time string YYYY-MM-DD hh:mm:ss for the current time.

Returns
std::string current time string.

◆ Info()

static EXTERNAL void KS::Log::Info ( const std::string &  message,
const std::string &  channel = "Root" 
)
static

Write an INFO log message

Parameters
conststd::string& message to log.
conststd::string& channel to log to

◆ Instance()

static EXTERNAL std::shared_ptr<Log> KS::Log::Instance ( )
static

Create or return a pointer to the log object

Returns
std::shared_ptr<Log> - log pointer

◆ RegisterCallback()

EXTERNAL void KS::Log::RegisterCallback ( const std::string &  channel,
LogHandler  handler,
uint8_t  levels,
bool  allowBubbling 
)

Register a log handler for a specific channel and log level

Parameters
conststd::string& channel
LogHandlerlog handler
LogLevellog level
boolallowBubbling - if false, logs handled by this handler will not be processed by handlers on parent channels.

◆ SetInstance()

static EXTERNAL void KS::Log::SetInstance ( std::shared_ptr< Log logPtr)
static

Assign the static instance to a specific log

Parameters
std::shared_ptr<Log>

◆ UnregisterCallback()

EXTERNAL void KS::Log::UnregisterCallback ( const std::string &  channel,
LogHandler  handler 
)

Unregister a log handler for a specific channel and log level

Parameters
conststd::string& channel
LogHandlerlog handler

◆ Warning()

static EXTERNAL void KS::Log::Warning ( const std::string &  message,
const std::string &  channel = "Root" 
)
static

Write a WARNING log message

Parameters
conststd::string& message to log
conststd::string& channel to log to

◆ Write()

EXTERNAL void KS::Log::Write ( const std::string &  message,
const std::string &  channel,
LogLevel  level 
)

Parses a channel into a channel hierarchy (See above) and calls the handlers for each level starting with the lowest level and working up the hierarchy until 'Root'. If a handler has been registered with 'allowBubbling' set to false then all parent handlers will be skipped.

Parameters
conststd::string& message
conststd::string& channel
LogLevellog level

The documentation for this class was generated from the following file: