Class Logs
The IdleKit logging class. Use this to output log messages and handle exceptions. It is configurable per IEnvironmentConfig by creating ILoggingEnvironmentConfig objects.
Inherited Members
Namespace: IdleKit.Core
Assembly: cs.temp.dll.dll
Syntax
public static class Logs
Properties
CurrentEnvironmentConfig
Declaration
public static IEnvironmentConfig CurrentEnvironmentConfig { get; }
Property Value
Type | Description |
---|---|
IEnvironmentConfig |
Editor
Declaration
public static ILogCategory Editor { get; }
Property Value
Type | Description |
---|---|
ILogCategory |
Logger
Declaration
public static IIKLogger Logger { get; }
Property Value
Type | Description |
---|---|
IIKLogger |
LogModule
Declaration
public static ILogCategory LogModule { get; }
Property Value
Type | Description |
---|---|
ILogCategory |
Uncategorized
Declaration
public static ILogCategory Uncategorized { get; }
Property Value
Type | Description |
---|---|
ILogCategory |
Methods
ApplyConfig(ILoggingConfig, IEnvironmentConfig)
Applies a new IEnvironmentConfig and ILoggingEnvironmentConfig.
Declaration
public static void ApplyConfig(ILoggingConfig config, IEnvironmentConfig environmentConfig)
Parameters
Type | Name | Description |
---|---|---|
ILoggingConfig | config | The ILoggingConfig to use. |
IEnvironmentConfig | environmentConfig | The IEnvironmentConfig to use to retrieve the correct ILoggingEnvironmentConfig. |
ApplyEnvironmentConfig(ILoggingEnvironmentConfig)
Applies a new ILoggingEnvironmentConfig directly.
Declaration
public static void ApplyEnvironmentConfig(ILoggingEnvironmentConfig envConfig)
Parameters
Type | Name | Description |
---|---|---|
ILoggingEnvironmentConfig | envConfig | The ILoggingEnvironmentConfig to apply. |
Cleanup()
Cleans up the logging system state.
Declaration
public static void Cleanup()
ClearLogs(Func<LogEntry, Boolean>)
Clears all logs that meet the criteria of the clearPredicate
.
Declaration
public static void ClearLogs(Func<LogEntry, bool> clearPredicate = null)
Parameters
Type | Name | Description |
---|---|---|
Func<LogEntry, Boolean> | clearPredicate | A method that determines which LogEntrys need to be cleared. |
GetLogs(LogSeverity, Func<LogEntry, Boolean>)
Returns all LogEntrys that match the provided LogSeverity and meet the selectionPredicate
criteria.
Declaration
public static List<LogEntry> GetLogs(LogSeverity severityMask, Func<LogEntry, bool> selectionPredicate = null)
Parameters
Type | Name | Description |
---|---|---|
LogSeverity | severityMask | The LogSeverity of the LogEntrys to return. |
Func<LogEntry, Boolean> | selectionPredicate | A method that determines which LogEntrys should be returned. |
Returns
Type | Description |
---|---|
List<LogEntry> |
HandleException(Exception, ILogCategory)
Handles an exception through the active IIKLogger.
Declaration
public static void HandleException(Exception exception, ILogCategory category = null)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | The exception to handle. |
ILogCategory | category | The ILogCategory to organize a message under if the exception is not thrown. |
Initialize(IIKLogger, ILoggingConfig, IEnvironmentConfig)
Initializes logging. The logging system can be initialized with or without a IIKLogger, ILoggingConfig and IEnvironmentConfig. It has default behaviour for any combination of initialization arguments.
Declaration
public static void Initialize(IIKLogger newLogger = null, ILoggingConfig config = null, IEnvironmentConfig environmentConfig = null)
Parameters
Type | Name | Description |
---|---|---|
IIKLogger | newLogger | The IIKLogger to use when outputting messages and handling exceptions. |
ILoggingConfig | config | The ILoggingConfig to use for various logging settings. |
IEnvironmentConfig | environmentConfig | The IEnvironmentConfig to use to determine what ILoggingEnvironmentConfig to use. |
IsCategoryActive(ILogCategory)
Returns true if the provided ILogCategory is currently active.
Declaration
public static bool IsCategoryActive(ILogCategory category)
Parameters
Type | Name | Description |
---|---|---|
ILogCategory | category | The ILogCategory to check. |
Returns
Type | Description |
---|---|
Boolean |
Log(LogSeverity, String, ILogCategory)
Logs a message to the active IIKLogger.
Declaration
public static void Log(LogSeverity severity, string message, ILogCategory category = null)
Parameters
Type | Name | Description |
---|---|---|
LogSeverity | severity | The LogSeverity of the message. |
String | message | The message to log. |
ILogCategory | category | The ILogCategory that this message should be organized under. |
RemoveConfig()
Removes the currently active IEnvironmentConfig.
Declaration
public static void RemoveConfig()
ToggleCategory(ILogCategory, Boolean)
Allows for a ILogCategory to be enabled or disabled. Disabled categories will not appear in output from IIKLoggers.
Declaration
public static void ToggleCategory(ILogCategory category, bool isActive)
Parameters
Type | Name | Description |
---|---|---|
ILogCategory | category | The ILogCategory to change. |
Boolean | isActive | If true, the category will be active. |
ToggleCategoryId(String, Boolean)
Allows for a ILogCategory to be enabled or disabled. Disabled categories will not appear in output from IIKLoggers.
Declaration
public static void ToggleCategoryId(string categoryId, bool isActive)
Parameters
Type | Name | Description |
---|---|---|
String | categoryId | The ID of the ILogCategory to change. |
Boolean | isActive | If true, the category will be active. |
ToggleCustomStackTraces(Boolean)
Allows for custom stack traces to be enabled or disabled. Custom stack traces reduce clutter in output.
Declaration
public static void ToggleCustomStackTraces(bool isActive)
Parameters
Type | Name | Description |
---|---|---|
Boolean | isActive | If true, custom stack traces will be used. |
ToggleTagColorsInLogs(Boolean)
Allows for tags to be colored. Color helps distinguish the various systems from each other when reading logs.
Declaration
public static void ToggleTagColorsInLogs(bool colorTags)
Parameters
Type | Name | Description |
---|---|---|
Boolean | colorTags | If true, tags will be colored. |
ToggleTagsInLogs(Boolean)
Allows for tags to be enabled or disabled. Disabled tags will not appear in output from IIKLoggers.
Declaration
public static void ToggleTagsInLogs(bool showTags)
Parameters
Type | Name | Description |
---|---|---|
Boolean | showTags | If true, the tags will appear in output. |
ToggleThrowExceptions(Boolean)
Allows for exceptions to be thrown or logged.
Declaration
public static void ToggleThrowExceptions(bool throwExceptions)
Parameters
Type | Name | Description |
---|---|---|
Boolean | throwExceptions | If true, exceptions will throw, otherwise they will be logged. |
Events
OnExceptionHandled
Declaration
public static event Action<Exception> OnExceptionHandled
Event Type
Type | Description |
---|---|
Action<Exception> |