Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nekomimi-daimao
Created July 13, 2021 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nekomimi-daimao/d749e64b064856799ee0b039385b482a to your computer and use it in GitHub Desktop.
Save nekomimi-daimao/d749e64b064856799ee0b039385b482a to your computer and use it in GitHub Desktop.
試作
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