Logging#
Helper methods for sending messages to the Unity debug log with the name of your mod and object context
- namespace KSPCommunityLib.Logging#
- interface ILogContextProvider#
Interface for providing context to log messages.
Implementing this interface on a class allows the
LogMessage,LogDebugandLogErrorextension methods to be called on it, or override the default context used for classes inheriting from UnityEngine.Object.Public Functions
- string LoggingContext ()#
- return:
A string with the context for a log message sent from this object, for example a PartModule name
- class Log#
Static class with functions to send messages to the Unity log with context.
Package Static Functions
- void Debug (string message, string prefix = "")#
Log a debug message to the Unity log. Only included in Debug builds, on Release builds this does nothing
- Param message:
Message to write to the log
- Param prefix:
Prefix to prepend the message with
- void Message (string message, string prefix = "")#
Log a message to the Unity log.
- Param message:
Message to write to the log
- Param prefix:
Prefix to prepend the message with
- void Warning (string message, string prefix = "")#
Log a warning message to the Unity log.
- Param message:
Message to write to the log
- Param prefix:
Prefix to prepend the message with
- void Error (string message, string prefix = "")#
Log an error message to the Unity log.
- Param message:
Message to write to the log
- Param prefix:
Prefix to prepend the message with
Package Static Attributes
- string ModPrefix = "[" + Assembly.GetExecutingAssembly().GetName().Name + "]"#
String prepended to all log messages to identify which mod they originate with.
Defaults to the assembly name. You can overwrite this field to use a custom mod name, but for consistency please wrap it in square brackets
- class LogExtensions#
Extension methods added to all UnityEngine.Object objects or those implementing ILogContextProvider.
Package Static Functions
- void LogDebug (this UnityEngine.Object obj, string message, string prefix = "")#
Call Log.Debug with
thisobject as context.
- void LogDebug (this ILogContextProvider obj, string message, string prefix = "")
Call Log.Debug with
thisobject as context.
- void LogMessage (this UnityEngine.Object obj, string message, string prefix = "")#
Call Log.Message with
thisobject as context.
- void LogMessage (this ILogContextProvider obj, string message, string prefix = "")
Call Log.Message with
thisobject as context.
- void LogWarning (this UnityEngine.Object obj, string message, string prefix = "")#
Call Log.Warning with
thisobject as context.
- void LogWarning (this ILogContextProvider obj, string message, string prefix = "")
Call Log.Warning with
thisobject as context.
- void LogError (this UnityEngine.Object obj, string message, string prefix = "")#
Call Log.Error with
thisobject as context.
- void LogError (this ILogContextProvider obj, string message, string prefix = "")
Call Log.Error with
thisobject as context.