KS.Reactor.ksLog Class Reference

Static logger class. More...

Public Types

enum class  Level : byte {
  ALL = 0xFF , PRODUCTION = 0xFE , DEBUG = 1 , INFO = 2 ,
  WARNING = 4 , ERROR = 8 , FATAL = 16
}
 Log levels. More...
 

Public Member Functions

delegate void LogHandler (Level level, string channel, string message, Exception exception, object context)
 Delegate for logging a message. More...
 

Static Public Member Functions

static void Debug< T > (T channel, string message)
 Logs a debug message. More...
 
static void Debug (string message)
 Logs a debug message to the root channel. More...
 
static void Debug< T > (T channel, string message, object context)
 Logs a debug message. More...
 
static void Debug (string message, object context)
 Logs a debug message to the root channel. More...
 
static void Info< T > (T channel, string message)
 Logs an info message. More...
 
static void Info (string message)
 Logs an info message to the root channel. More...
 
static void Info< T > (T channel, string message, object context)
 Logs an info message. More...
 
static void Info (string message, object context)
 Logs an info message to the root channel. More...
 
static void Warning< T > (T channel, string message)
 Logs a warning. More...
 
static void Warning (string message)
 Logs a warning to the root channel. More...
 
static void Warning< T > (T channel, string message, object context)
 Logs a warning. More...
 
static void Warning (string message, object context)
 Logs a warning to the root channel. More...
 
static void Error< T > (T channel, string message)
 Logs an error. More...
 
static void Error< T > (T channel, string message, Exception exception)
 Logs an error. More...
 
static void Error (string message)
 Logs an error to the root channel. More...
 
static void Error (string message, Exception exception)
 Logs an error to the root channel. More...
 
static void Error< T > (T channel, string message, object context)
 Logs an error. More...
 
static void Error< T > (T channel, string message, Exception exception, object context)
 Logs an error. More...
 
static void Error (string message, object context)
 Logs an error to the root channel. More...
 
static void Error (string message, Exception exception, object context)
 Logs an error to the root channel. More...
 
static void LogException< T > (T channel, Exception exception)
 Logs an exception. More...
 
static void LogException (Exception exception)
 Logs an exception to the root channel. More...
 
static void LogException< T > (T channel, Exception exception, object context)
 Logs an exception. More...
 
static void LogException (Exception exception, object context)
 Logs an exception to the root channel. More...
 
static void Fatal< T > (T channel, string message, Exception exception=null)
 Logs a fatal error. More...
 
static void Fatal (string message, Exception exception=null)
 Logs a fatal error to the root channel. More...
 
static void Fatal< T > (T channel, string message, object context, Exception exception=null)
 Logs a fatal error. More...
 
static void Fatal (string message, object context, Exception exception=null)
 Logs a fatal error to the root channel. More...
 
static void FatalException< T > (T channel, Exception exception)
 Logs a fatal exception. More...
 
static void FatalException (Exception exception)
 Logs a fatal exception to the root channel. More...
 
static void FatalException< T > (T channel, Exception exception, object context)
 Logs a fatal exception. More...
 
static void FatalException (Exception exception, object context)
 Logs a fatal exception to the root channel. More...
 
static void RegisterHandler< T > (T channel, LogHandler handler, Level levelMask=Level.ALL, bool allowBubbling=true)
 Registers a log handler. More...
 
static void RegisterHandler (LogHandler handler, Level levelMask=Level.ALL, bool allowBubbling=true)
 Registers a log handler to the root channel. More...
 
static bool UnregisterHandler< T > (T channel, LogHandler handler)
 Unregisters a log handler. More...
 
static bool UnregisterHandler (LogHandler handler)
 Unregisters a log handler from the root channel. More...
 
static void LogToUnity (Level level, string channel, string message, Exception e, object context)
 Passes a log message to Unity's logger. More...
 

Static Public Attributes

const string ROOT_CHANNEL = "Root"
 Name of the root channel. More...
 
const string VERBOSE_CHANNEL = "Verbose"
 Name of the verbose channel. More...
 
const int MAX_LENGTH = 15000
 Maximum number of characters in a log statement before it is split up into multiple log statements. More...
 

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. If a non-string object is passed as channel parameter T to a log function, the channel string will be [namespace.classname]. Example: ksLog.Info("X.Y", "This message will be received by channels 'X.Y', 'X', and 'Root');

Member Enumeration Documentation

◆ Level

enum KS.Reactor.ksLog.Level : byte
strong

Log levels.

Member Function Documentation

◆ Debug() [1/2]

static void KS.Reactor.ksLog.Debug ( string  message)
static

Logs a debug message to the root channel.

Parameters
messageMessage to log.

◆ Debug() [2/2]

static void KS.Reactor.ksLog.Debug ( string  message,
object  context 
)
static

Logs a debug message to the root channel.

Parameters
messageMessage to log.
contextObject related to this message.

◆ Debug< T >() [1/2]

static void KS.Reactor.ksLog.Debug< T > ( channel,
string  message 
)
static

Logs a debug message.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
Type Constraints
T :class 

◆ Debug< T >() [2/2]

static void KS.Reactor.ksLog.Debug< T > ( channel,
string  message,
object  context 
)
static

Logs a debug message.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
contextObject related to this message.
Type Constraints
T :class 

◆ Error() [1/4]

static void KS.Reactor.ksLog.Error ( string  message)
static

Logs an error to the root channel.

Parameters
messageMessage to log.

◆ Error() [2/4]

static void KS.Reactor.ksLog.Error ( string  message,
Exception  exception 
)
static

Logs an error to the root channel.

Parameters
messageMessage to log.
exceptionException to log.

◆ Error() [3/4]

static void KS.Reactor.ksLog.Error ( string  message,
Exception  exception,
object  context 
)
static

Logs an error to the root channel.

Parameters
messageMessage to log.
exceptionException to log.
contextObject related to this message.

◆ Error() [4/4]

static void KS.Reactor.ksLog.Error ( string  message,
object  context 
)
static

Logs an error to the root channel.

Parameters
messageMessage to log.
contextObject related to this message.

◆ Error< T >() [1/4]

static void KS.Reactor.ksLog.Error< T > ( channel,
string  message 
)
static

Logs an error.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
Type Constraints
T :class 

◆ Error< T >() [2/4]

static void KS.Reactor.ksLog.Error< T > ( channel,
string  message,
Exception  exception 
)
static

Logs an error.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
exceptionException to log.
Type Constraints
T :class 

◆ Error< T >() [3/4]

static void KS.Reactor.ksLog.Error< T > ( channel,
string  message,
Exception  exception,
object  context 
)
static

Logs an error.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
exceptionException to log.
contextObject related to this message.
Type Constraints
T :class 

◆ Error< T >() [4/4]

static void KS.Reactor.ksLog.Error< T > ( channel,
string  message,
object  context 
)
static

Logs an error.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
contextObject related to this message.
Type Constraints
T :class 

◆ Fatal() [1/2]

static void KS.Reactor.ksLog.Fatal ( string  message,
Exception  exception = null 
)
static

Logs a fatal error to the root channel.

Parameters
messageMessage to log.
exceptionException to log.

◆ Fatal() [2/2]

static void KS.Reactor.ksLog.Fatal ( string  message,
object  context,
Exception  exception = null 
)
static

Logs a fatal error to the root channel.

Parameters
messageMessage to log.
contextObject related to this message.
exceptionException to log.

◆ Fatal< T >() [1/2]

static void KS.Reactor.ksLog.Fatal< T > ( channel,
string  message,
Exception  exception = null 
)
static

Logs a fatal error.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
exceptionException to log.
Type Constraints
T :class 

◆ Fatal< T >() [2/2]

static void KS.Reactor.ksLog.Fatal< T > ( channel,
string  message,
object  context,
Exception  exception = null 
)
static

Logs a fatal error.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
contextObject related to this message.
exceptionException to log.
Type Constraints
T :class 

◆ FatalException() [1/2]

static void KS.Reactor.ksLog.FatalException ( Exception  exception)
static

Logs a fatal exception to the root channel.

Parameters
exceptionException to log.

◆ FatalException() [2/2]

static void KS.Reactor.ksLog.FatalException ( Exception  exception,
object  context 
)
static

Logs a fatal exception to the root channel.

Parameters
exceptionException to log.
contextObject related to this message.

◆ FatalException< T >() [1/2]

static void KS.Reactor.ksLog.FatalException< T > ( channel,
Exception  exception 
)
static

Logs a fatal exception.

Template Parameters
T
Parameters
channelChannel to log to.
exceptionException to log.
Type Constraints
T :class 

◆ FatalException< T >() [2/2]

static void KS.Reactor.ksLog.FatalException< T > ( channel,
Exception  exception,
object  context 
)
static

Logs a fatal exception.

Template Parameters
T
Parameters
channelChannel to log to.
exceptionException to log.
contextObject related to this message.
Type Constraints
T :class 

◆ Info() [1/2]

static void KS.Reactor.ksLog.Info ( string  message)
static

Logs an info message to the root channel.

Parameters
messageMessage to log.

◆ Info() [2/2]

static void KS.Reactor.ksLog.Info ( string  message,
object  context 
)
static

Logs an info message to the root channel.

Parameters
messageMessage to log.
contextObject related to this message.

◆ Info< T >() [1/2]

static void KS.Reactor.ksLog.Info< T > ( channel,
string  message 
)
static

Logs an info message.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
Type Constraints
T :class 

◆ Info< T >() [2/2]

static void KS.Reactor.ksLog.Info< T > ( channel,
string  message,
object  context 
)
static

Logs an info message.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
contextObject related to this message.
Type Constraints
T :class 

◆ LogException() [1/2]

static void KS.Reactor.ksLog.LogException ( Exception  exception)
static

Logs an exception to the root channel.

Parameters
exceptionException to log.

◆ LogException() [2/2]

static void KS.Reactor.ksLog.LogException ( Exception  exception,
object  context 
)
static

Logs an exception to the root channel.

Parameters
exceptionException to log.
contextObject related to this message.

◆ LogException< T >() [1/2]

static void KS.Reactor.ksLog.LogException< T > ( channel,
Exception  exception 
)
static

Logs an exception.

Template Parameters
T
Parameters
channelChannel to log to.
exceptionException to log.
Type Constraints
T :class 

◆ LogException< T >() [2/2]

static void KS.Reactor.ksLog.LogException< T > ( channel,
Exception  exception,
object  context 
)
static

Logs an exception.

Template Parameters
T
Parameters
channelChannel to log to.
exceptionException to log.
contextObject related to this message.
Type Constraints
T :class 

◆ LogHandler()

delegate void KS.Reactor.ksLog.LogHandler ( Level  level,
string  channel,
string  message,
Exception  exception,
object  context 
)

Delegate for logging a message.

Parameters
levelLevel of the message.
channelChannel the message was sent to.
messageMessage to log. May be null if exception is provided.
exceptionException to log. May be null if message is provided.
contextObject related to this message.

◆ LogToUnity()

static void KS.Reactor.ksLog.LogToUnity ( Level  level,
string  channel,
string  message,
Exception  e,
object  context 
)
static

Passes a log message to Unity's logger.

Parameters
levellevel of the message.
channelchannel the message was sent to.
messagemessage to log. May be null if exception is provided.
exceptionexception to log. May be null if message is provided.
contextobject related to this message.

◆ RegisterHandler()

static void KS.Reactor.ksLog.RegisterHandler ( LogHandler  handler,
Level  levelMask = Level.ALL,
bool  allowBubbling = true 
)
static

Registers a log handler to the root channel.

Parameters
handlerHandler to register.
levelMaskFilters messages by level.
allowBubblingIf false, logs handled by this handler will not be processed by handlers on parent channels.

◆ RegisterHandler< T >()

static void KS.Reactor.ksLog.RegisterHandler< T > ( channel,
LogHandler  handler,
Level  levelMask = Level.ALL,
bool  allowBubbling = true 
)
static

Registers a log handler.

Template Parameters
T
Parameters
channelChannel to register to.
handlerHandler to register.
levelMaskFilters messages by level.
allowBubblingIf false, logs handled by this handler will not be processed by handlers on parent channels.
Type Constraints
T :class 

◆ UnregisterHandler()

static bool KS.Reactor.ksLog.UnregisterHandler ( LogHandler  handler)
static

Unregisters a log handler from the root channel.

Parameters
handlerHandler to unregister.
Returns
True if the handler was found and removed.

◆ UnregisterHandler< T >()

static bool KS.Reactor.ksLog.UnregisterHandler< T > ( channel,
LogHandler  handler 
)
static

Unregisters a log handler.

Template Parameters
T
Parameters
channelChannel to unregister from.
handlerHandler to unregister.
Returns
True if the handler was found and removed.
Type Constraints
T :class 

◆ Warning() [1/2]

static void KS.Reactor.ksLog.Warning ( string  message)
static

Logs a warning to the root channel.

Parameters
messageMessage to log.

◆ Warning() [2/2]

static void KS.Reactor.ksLog.Warning ( string  message,
object  context 
)
static

Logs a warning to the root channel.

Parameters
messageMessage to log.
contextObject related to this message.

◆ Warning< T >() [1/2]

static void KS.Reactor.ksLog.Warning< T > ( channel,
string  message 
)
static

Logs a warning.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
Type Constraints
T :class 

◆ Warning< T >() [2/2]

static void KS.Reactor.ksLog.Warning< T > ( channel,
string  message,
object  context 
)
static

Logs a warning.

Template Parameters
T
Parameters
channelChannel to log to.
messageMessage to log.
contextObject related to this message.
Type Constraints
T :class 

Member Data Documentation

◆ MAX_LENGTH

const int KS.Reactor.ksLog.MAX_LENGTH = 15000
static

Maximum number of characters in a log statement before it is split up into multiple log statements.

This is to prevent Unity from breaking because a log statement is too long. This is a bit shorter than Unity's maximum (16384) since some extra text is added to each message (log level, channel, etc.).

◆ ROOT_CHANNEL

const string KS.Reactor.ksLog.ROOT_CHANNEL = "Root"
static

Name of the root channel.

◆ VERBOSE_CHANNEL

const string KS.Reactor.ksLog.VERBOSE_CHANNEL = "Verbose"
static

Name of the verbose channel.