/// <summary> /// removes a new logger to the logger list. /// </summary> /// <remarks> /// By removing your logger from the list of registered loggers, it doesn`t receive any further log messages. This method can be called at runtime to deactivate loggers. /// </remarks> /// <example> /// How to remove a logger to the KGFDebug class /// <code> /// public class KGFSampleLogger : MonoBehaviour, KGFIDebug /// { /// public void Awake() /// { /// KGFDebug.AddLogger(this); /// } /// } /// /// public class MyGameScript : MonoBehaviour /// { /// private KGFIDebug itsLogger = new KGFSampleLogger(); /// /// public void Awake() /// { /// //activate the Logger /// KGFDebug.AddLogger(itsLogger); /// } /// /// public void Start() /// { /// //deactivate the Logger /// KGFDebug.RemoveLogger(itsLogger); /// } /// } /// </code> /// </example> /// <param name="theLogger">instance of the logger that should be added to the list</param> public static void RemoveLogger(KGFIDebug theLogger) { CheckInstance(); if (itsRegisteredLogger.Contains(theLogger)) { itsRegisteredLogger.Remove(theLogger); } else { UnityEngine.Debug.LogError("the logger you tried to remove wasnt found."); } }
/// <summary> /// Adds a new logger to the logger list. /// </summary> /// <remarks> /// Loggers can be used to process the input of the KGFDebug class in a custom way. For example display messages on screen, write them into /// a file or end them to a webserver. To create your own logger implement the KGFIDebug interface and attach your instance to the KGFDebug class by /// calling Add(). An instance of a logger can be added only once, but there can be multiple loggers with the same name. /// </remarks> /// <example> /// How to add a logger to the KGFDebug class /// <code> /// public class KGFSampleLogger : MonoBehaviour, KGFIDebug /// { /// public void Start() /// { /// KGFDebug.AddLogger(this); /// } /// } /// </code> /// </example> /// <param name="theLogger">instance of the logger that should be added to the list</param> public static void AddLogger(KGFIDebug theLogger) { CheckInstance(); if (!itsRegisteredLogger.Contains(theLogger)) { itsRegisteredLogger.Add(theLogger); if (itsCachedLogs != null) { foreach (KGFDebugLog aLog in itsCachedLogs) { theLogger.Log(aLog); } } } else { UnityEngine.Debug.LogError("this logger is already registered."); } }