Created
June 22, 2017 02:48
-
-
Save keiranlovett/70581c6c7f602bbbef701a42db3bfea0 to your computer and use it in GitHub Desktop.
unity: Debug Logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
/// <summary> | |
/// A logger that wraps Unity's internal logger. | |
/// Calls to its methods are stripped in case the LOGGER_SYMBOL is not defined. | |
/// </summary> | |
public sealed class Logger | |
{ | |
public const string LOGGER_SYMBOL = "ENABLE_LOG"; | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void Log(object message) | |
{ | |
Debug.Log(message); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void Log(object message, Object context) | |
{ | |
Debug.Log(message, context); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogFormat(string message, params object[] args) | |
{ | |
Debug.LogFormat(message, args); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogFormat(Object context, string message, params object[] args) | |
{ | |
Debug.LogFormat(context, message, args); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogWarning(object message) | |
{ | |
Debug.LogWarning(message); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogWarning(object message, Object context) | |
{ | |
Debug.LogWarning(message, context); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogWarningFormat(string message, params object[] args) | |
{ | |
Debug.LogWarningFormat(message, args); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogWarningFormat(Object context, string message, params object[] args) | |
{ | |
Debug.LogWarningFormat(context, message, args); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogError(object message) | |
{ | |
Debug.LogError(message); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogError(object message, Object context) | |
{ | |
Debug.LogError(message, context); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogErrorFormat(string message, params object[] args) | |
{ | |
Debug.LogErrorFormat(message, args); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogErrorFormat(Object context, string message, params object[] args) | |
{ | |
Debug.LogErrorFormat(context, message, args); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogException(System.Exception exception) | |
{ | |
Debug.LogException(exception); | |
} | |
[System.Diagnostics.Conditional(LOGGER_SYMBOL)] | |
public static void LogException(System.Exception exception, Object context) | |
{ | |
Debug.LogException(exception, context); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment