試作
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 System; | |
using UnityEngine; | |
public static class L | |
{ | |
private const string DefineConditional = "NEVER_DEFINED_SYMBOL"; | |
#region LogLevel | |
public enum LogLevel : byte | |
{ | |
All, | |
Verbose, | |
Info, | |
Debug, | |
Warning, | |
Error, | |
Off, | |
} | |
public static LogLevel CurrentLogLevel = LogLevel.Debug; | |
#endregion | |
#region Log | |
#if !(UNITY_EDITOR || DEVELOPMENT_BUILD) | |
[Conditional(DefineConditional)] | |
#endif | |
private static void LogInternal(LogLevel level, object message) | |
{ | |
if (level < CurrentLogLevel) | |
{ | |
return; | |
} | |
if (level == LogLevel.Error) | |
{ | |
Debug.LogError(message); | |
} | |
else if (level == LogLevel.Warning) | |
{ | |
Debug.LogWarning(message); | |
} | |
else | |
{ | |
Debug.Log(message); | |
} | |
} | |
#if !(UNITY_EDITOR || DEVELOPMENT_BUILD) | |
[Conditional(DefineConditional)] | |
#endif | |
public static void V(object message) | |
{ | |
LogInternal(LogLevel.Verbose, message); | |
} | |
#if !(UNITY_EDITOR || DEVELOPMENT_BUILD) | |
[Conditional(DefineConditional)] | |
#endif | |
public static void I(object message) | |
{ | |
LogInternal(LogLevel.Info, message); | |
} | |
#if !(UNITY_EDITOR || DEVELOPMENT_BUILD) | |
[Conditional(DefineConditional)] | |
#endif | |
public static void D(object message) | |
{ | |
LogInternal(LogLevel.Debug, message); | |
} | |
#if !(UNITY_EDITOR || DEVELOPMENT_BUILD) | |
[Conditional(DefineConditional)] | |
#endif | |
public static void W(object message) | |
{ | |
LogInternal(LogLevel.Warning, message); | |
} | |
#if !(UNITY_EDITOR || DEVELOPMENT_BUILD) | |
[Conditional(DefineConditional)] | |
#endif | |
public static void E(object message) | |
{ | |
LogInternal(LogLevel.Error, message); | |
} | |
#if !(UNITY_EDITOR || DEVELOPMENT_BUILD) | |
[Conditional(DefineConditional)] | |
#endif | |
public static void Exception(Exception e) | |
{ | |
if (CurrentLogLevel == LogLevel.Off) | |
{ | |
return; | |
} | |
Debug.LogException(e); | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment