> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.kslog.md).

# Class ksLog

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

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');

```csharp
public class ksLog
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksLog](/reactor/api-reference/ks.reactor/ks.reactor.kslog.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Fields

### MAX\_LENGTH <a href="#ks_reactor_kslog_max_length" id="ks_reactor_kslog_max_length"></a>

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.).

```csharp
public const int MAX_LENGTH = 15000
```

#### Field Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### ROOT\_CHANNEL <a href="#ks_reactor_kslog_root_channel" id="ks_reactor_kslog_root_channel"></a>

Name of the root channel.

```csharp
public const string ROOT_CHANNEL = "Root"
```

#### Field Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

### TEST\_CHANNEL <a href="#ks_reactor_kslog_test_channel" id="ks_reactor_kslog_test_channel"></a>

Name of the test channel that is not supressed during unit tests.

```csharp
public const string TEST_CHANNEL = "Test"
```

#### Field Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

### VERBOSE\_CHANNEL <a href="#ks_reactor_kslog_verbose_channel" id="ks_reactor_kslog_verbose_channel"></a>

Name of the verbose channel.

```csharp
public const string VERBOSE_CHANNEL = "Verbose"
```

#### Field Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

## Methods

### Debug\<T>(T, string) <a href="#ks_reactor_kslog_debug__1___0_system_string" id="ks_reactor_kslog_debug__1___0_system_string"></a>

Logs a debug message.

```csharp
[HideInCallstack]
public static void Debug<T>(T channel, string message) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

#### Type Parameters

`T`

### Debug(string) <a href="#ks_reactor_kslog_debug_system_string" id="ks_reactor_kslog_debug_system_string"></a>

Logs a debug message to the root channel.

```csharp
[HideInCallstack]
public static void Debug(string message)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

### Debug\<T>(T, string, object) <a href="#ks_reactor_kslog_debug__1___0_system_string_system_object" id="ks_reactor_kslog_debug__1___0_system_string_system_object"></a>

Logs a debug message.

```csharp
[HideInCallstack]
public static void Debug<T>(T channel, string message, object context) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

#### Type Parameters

`T`

### Debug(string, object) <a href="#ks_reactor_kslog_debug_system_string_system_object" id="ks_reactor_kslog_debug_system_string_system_object"></a>

Logs a debug message to the root channel.

```csharp
[HideInCallstack]
public static void Debug(string message, object context)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

### Error\<T>(T, string) <a href="#ks_reactor_kslog_error__1___0_system_string" id="ks_reactor_kslog_error__1___0_system_string"></a>

Logs an error.

```csharp
[HideInCallstack]
public static void Error<T>(T channel, string message) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

#### Type Parameters

`T`

### Error\<T>(T, string, Exception) <a href="#ks_reactor_kslog_error__1___0_system_string_system_exception" id="ks_reactor_kslog_error__1___0_system_string_system_exception"></a>

Logs an error.

```csharp
[HideInCallstack]
public static void Error<T>(T channel, string message, Exception exception) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

#### Type Parameters

`T`

### Error(string) <a href="#ks_reactor_kslog_error_system_string" id="ks_reactor_kslog_error_system_string"></a>

Logs an error to the root channel.

```csharp
[HideInCallstack]
public static void Error(string message)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

### Error(string, Exception) <a href="#ks_reactor_kslog_error_system_string_system_exception" id="ks_reactor_kslog_error_system_string_system_exception"></a>

Logs an error to the root channel.

```csharp
[HideInCallstack]
public static void Error(string message, Exception exception)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

### Error\<T>(T, string, object) <a href="#ks_reactor_kslog_error__1___0_system_string_system_object" id="ks_reactor_kslog_error__1___0_system_string_system_object"></a>

Logs an error.

```csharp
[HideInCallstack]
public static void Error<T>(T channel, string message, object context) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

#### Type Parameters

`T`

### Error\<T>(T, string, Exception, object) <a href="#ks_reactor_kslog_error__1___0_system_string_system_exception_system_object" id="ks_reactor_kslog_error__1___0_system_string_system_exception_system_object"></a>

Logs an error.

```csharp
[HideInCallstack]
public static void Error<T>(T channel, string message, Exception exception, object context) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

#### Type Parameters

`T`

### Error(string, object) <a href="#ks_reactor_kslog_error_system_string_system_object" id="ks_reactor_kslog_error_system_string_system_object"></a>

Logs an error to the root channel.

```csharp
[HideInCallstack]
public static void Error(string message, object context)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

### Error(string, Exception, object) <a href="#ks_reactor_kslog_error_system_string_system_exception_system_object" id="ks_reactor_kslog_error_system_string_system_exception_system_object"></a>

Logs an error to the root channel.

```csharp
[HideInCallstack]
public static void Error(string message, Exception exception, object context)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

### Fatal\<T>(T, string, Exception) <a href="#ks_reactor_kslog_fatal__1___0_system_string_system_exception" id="ks_reactor_kslog_fatal__1___0_system_string_system_exception"></a>

Logs a fatal error.

```csharp
[HideInCallstack]
public static void Fatal<T>(T channel, string message, Exception exception = null) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

#### Type Parameters

`T`

### Fatal(string, Exception) <a href="#ks_reactor_kslog_fatal_system_string_system_exception" id="ks_reactor_kslog_fatal_system_string_system_exception"></a>

Logs a fatal error to the root channel.

```csharp
[HideInCallstack]
public static void Fatal(string message, Exception exception = null)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

### Fatal\<T>(T, string, object, Exception) <a href="#ks_reactor_kslog_fatal__1___0_system_string_system_object_system_exception" id="ks_reactor_kslog_fatal__1___0_system_string_system_object_system_exception"></a>

Logs a fatal error.

```csharp
[HideInCallstack]
public static void Fatal<T>(T channel, string message, object context, Exception exception = null) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

#### Type Parameters

`T`

### Fatal(string, object, Exception) <a href="#ks_reactor_kslog_fatal_system_string_system_object_system_exception" id="ks_reactor_kslog_fatal_system_string_system_object_system_exception"></a>

Logs a fatal error to the root channel.

```csharp
[HideInCallstack]
public static void Fatal(string message, object context, Exception exception = null)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

### FatalException\<T>(T, Exception) <a href="#ks_reactor_kslog_fatalexception__1___0_system_exception" id="ks_reactor_kslog_fatalexception__1___0_system_exception"></a>

Logs a fatal exception.

```csharp
[HideInCallstack]
public static void FatalException<T>(T channel, Exception exception) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

#### Type Parameters

`T`

### FatalException(Exception) <a href="#ks_reactor_kslog_fatalexception_system_exception" id="ks_reactor_kslog_fatalexception_system_exception"></a>

Logs a fatal exception to the root channel.

```csharp
[HideInCallstack]
public static void FatalException(Exception exception)
```

#### Parameters

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

### FatalException\<T>(T, Exception, object) <a href="#ks_reactor_kslog_fatalexception__1___0_system_exception_system_object" id="ks_reactor_kslog_fatalexception__1___0_system_exception_system_object"></a>

Logs a fatal exception.

```csharp
[HideInCallstack]
public static void FatalException<T>(T channel, Exception exception, object context) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

#### Type Parameters

`T`

### FatalException(Exception, object) <a href="#ks_reactor_kslog_fatalexception_system_exception_system_object" id="ks_reactor_kslog_fatalexception_system_exception_system_object"></a>

Logs a fatal exception to the root channel.

```csharp
[HideInCallstack]
public static void FatalException(Exception exception, object context)
```

#### Parameters

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

### Info\<T>(T, string) <a href="#ks_reactor_kslog_info__1___0_system_string" id="ks_reactor_kslog_info__1___0_system_string"></a>

Logs an info message.

```csharp
[HideInCallstack]
public static void Info<T>(T channel, string message) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

#### Type Parameters

`T`

### Info(string) <a href="#ks_reactor_kslog_info_system_string" id="ks_reactor_kslog_info_system_string"></a>

Logs an info message to the root channel.

```csharp
[HideInCallstack]
public static void Info(string message)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

### Info\<T>(T, string, object) <a href="#ks_reactor_kslog_info__1___0_system_string_system_object" id="ks_reactor_kslog_info__1___0_system_string_system_object"></a>

Logs an info message.

```csharp
[HideInCallstack]
public static void Info<T>(T channel, string message, object context) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

#### Type Parameters

`T`

### Info(string, object) <a href="#ks_reactor_kslog_info_system_string_system_object" id="ks_reactor_kslog_info_system_string_system_object"></a>

Logs an info message to the root channel.

```csharp
[HideInCallstack]
public static void Info(string message, object context)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

### LogException\<T>(T, Exception) <a href="#ks_reactor_kslog_logexception__1___0_system_exception" id="ks_reactor_kslog_logexception__1___0_system_exception"></a>

Logs an exception.

```csharp
[HideInCallstack]
public static void LogException<T>(T channel, Exception exception) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

#### Type Parameters

`T`

### LogException(Exception) <a href="#ks_reactor_kslog_logexception_system_exception" id="ks_reactor_kslog_logexception_system_exception"></a>

Logs an exception to the root channel.

```csharp
[HideInCallstack]
public static void LogException(Exception exception)
```

#### Parameters

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

### LogException\<T>(T, Exception, object) <a href="#ks_reactor_kslog_logexception__1___0_system_exception_system_object" id="ks_reactor_kslog_logexception__1___0_system_exception_system_object"></a>

Logs an exception.

```csharp
[HideInCallstack]
public static void LogException<T>(T channel, Exception exception, object context) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

#### Type Parameters

`T`

### LogException(Exception, object) <a href="#ks_reactor_kslog_logexception_system_exception_system_object" id="ks_reactor_kslog_logexception_system_exception_system_object"></a>

Logs an exception to the root channel.

```csharp
[HideInCallstack]
public static void LogException(Exception exception, object context)
```

#### Parameters

`exception` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

Exception to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

### LogToUnity(Level, string, string, Exception, object) <a href="#ks_reactor_kslog_logtounity_ks_reactor_kslog_level_system_string_system_string_system_exception_syst" id="ks_reactor_kslog_logtounity_ks_reactor_kslog_level_system_string_system_string_system_exception_syst"></a>

Passes a log message to Unity's logger.

```csharp
[HideInCallstack]
public static void LogToUnity(ksLog.Level level, string channel, string message, Exception e, object context)
```

#### Parameters

`level` [ksLog](/reactor/api-reference/ks.reactor/ks.reactor.kslog.md).[Level](/reactor/api-reference/ks.reactor/ks.reactor.kslog/ks.reactor.kslog.level.md)

level of the message.

`channel` [string](https://learn.microsoft.com/dotnet/api/system.string)

channel the message was sent to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

message to log. May be null if exception is provided.

`e` [Exception](https://learn.microsoft.com/dotnet/api/system.exception)

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

object related to this message.

### RegisterHandler\<T>(T, LogHandler, Level, bool) <a href="#ks_reactor_kslog_registerhandler__1___0_ks_reactor_kslog_loghandler_ks_reactor_kslog_level_system_bo" id="ks_reactor_kslog_registerhandler__1___0_ks_reactor_kslog_loghandler_ks_reactor_kslog_level_system_bo"></a>

Registers a log handler.

```csharp
public static void RegisterHandler<T>(T channel, ksLog.LogHandler handler, ksLog.Level levelMask = Level.ALL, bool allowBubbling = true) where T : class
```

#### Parameters

`channel` T

Channel to register to.

`handler` [ksLog](/reactor/api-reference/ks.reactor/ks.reactor.kslog.md).[LogHandler](/reactor/api-reference/ks.reactor/ks.reactor.kslog/ks.reactor.kslog.loghandler.md)

Handler to register.

`levelMask` [ksLog](/reactor/api-reference/ks.reactor/ks.reactor.kslog.md).[Level](/reactor/api-reference/ks.reactor/ks.reactor.kslog/ks.reactor.kslog.level.md)

Filters messages by level.

`allowBubbling` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, logs handled by this handler will not be processed by handlers on parent channels.

#### Type Parameters

`T`

### RegisterHandler(LogHandler, Level, bool) <a href="#ks_reactor_kslog_registerhandler_ks_reactor_kslog_loghandler_ks_reactor_kslog_level_system_boolean" id="ks_reactor_kslog_registerhandler_ks_reactor_kslog_loghandler_ks_reactor_kslog_level_system_boolean"></a>

Registers a log handler to the root channel.

```csharp
public static void RegisterHandler(ksLog.LogHandler handler, ksLog.Level levelMask = Level.ALL, bool allowBubbling = true)
```

#### Parameters

`handler` [ksLog](/reactor/api-reference/ks.reactor/ks.reactor.kslog.md).[LogHandler](/reactor/api-reference/ks.reactor/ks.reactor.kslog/ks.reactor.kslog.loghandler.md)

Handler to register.

`levelMask` [ksLog](/reactor/api-reference/ks.reactor/ks.reactor.kslog.md).[Level](/reactor/api-reference/ks.reactor/ks.reactor.kslog/ks.reactor.kslog.level.md)

Filters messages by level.

`allowBubbling` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, logs handled by this handler will not be processed by handlers on parent channels.

### UnregisterHandler\<T>(T, LogHandler) <a href="#ks_reactor_kslog_unregisterhandler__1___0_ks_reactor_kslog_loghandler" id="ks_reactor_kslog_unregisterhandler__1___0_ks_reactor_kslog_loghandler"></a>

Unregisters a log handler.

```csharp
public static bool UnregisterHandler<T>(T channel, ksLog.LogHandler handler) where T : class
```

#### Parameters

`channel` T

Channel to unregister from.

`handler` [ksLog](/reactor/api-reference/ks.reactor/ks.reactor.kslog.md).[LogHandler](/reactor/api-reference/ks.reactor/ks.reactor.kslog/ks.reactor.kslog.loghandler.md)

Handler to unregister.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the handler was found and removed.

#### Type Parameters

`T`

### UnregisterHandler(LogHandler) <a href="#ks_reactor_kslog_unregisterhandler_ks_reactor_kslog_loghandler" id="ks_reactor_kslog_unregisterhandler_ks_reactor_kslog_loghandler"></a>

Unregisters a log handler from the root channel.

```csharp
public static bool UnregisterHandler(ksLog.LogHandler handler)
```

#### Parameters

`handler` [ksLog](/reactor/api-reference/ks.reactor/ks.reactor.kslog.md).[LogHandler](/reactor/api-reference/ks.reactor/ks.reactor.kslog/ks.reactor.kslog.loghandler.md)

Handler to unregister.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the handler was found and removed.

### Warning\<T>(T, string) <a href="#ks_reactor_kslog_warning__1___0_system_string" id="ks_reactor_kslog_warning__1___0_system_string"></a>

Logs a warning.

```csharp
[HideInCallstack]
public static void Warning<T>(T channel, string message) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

#### Type Parameters

`T`

### Warning(string) <a href="#ks_reactor_kslog_warning_system_string" id="ks_reactor_kslog_warning_system_string"></a>

Logs a warning to the root channel.

```csharp
[HideInCallstack]
public static void Warning(string message)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

### Warning\<T>(T, string, object) <a href="#ks_reactor_kslog_warning__1___0_system_string_system_object" id="ks_reactor_kslog_warning__1___0_system_string_system_object"></a>

Logs a warning.

```csharp
[HideInCallstack]
public static void Warning<T>(T channel, string message, object context) where T : class
```

#### Parameters

`channel` T

Channel to log to.

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.

#### Type Parameters

`T`

### Warning(string, object) <a href="#ks_reactor_kslog_warning_system_string_system_object" id="ks_reactor_kslog_warning_system_string_system_object"></a>

Logs a warning to the root channel.

```csharp
[HideInCallstack]
public static void Warning(string message, object context)
```

#### Parameters

`message` [string](https://learn.microsoft.com/dotnet/api/system.string)

Message to log.

`context` [object](https://learn.microsoft.com/dotnet/api/system.object)

Object related to this message.
