2023-04-03 11:04:31 +08:00

85 lines
2.3 KiB
C#

using System.Diagnostics;
using System;
namespace BF
{
public static class BFLog
{
public static bool DEBUG_RESMGR = false;
public static bool DEBUG_GAME_LAUNCH = true;
[Conditional("DEBUG")]
public static void LogDebug(bool condition, string color, string text, params object[] par)
{
if (condition)
UnityEngine.Debug.Log(GetColorOutput(color, text, par));
}
[Conditional("DEBUG")]
public static void LogDebug(string color, string text, params object[] par)
{
UnityEngine.Debug.Log(GetColorOutput(color, text, par));
}
[Conditional("DEBUG")]
public static void Log(string text, params object[] par)
{
UnityEngine.Debug.Log(GetOutput(text, par));
}
public static void LogWarning(string text, params object[] par)
{
UnityEngine.Debug.LogWarning(GetOutput(text, par));
}
public static void LogError(string text, params object[] par)
{
UnityEngine.Debug.LogError(GetOutput(text, par));
}
public static bool LogAssert(bool val, string text, params object[] par)
{
if (!val)
{
UnityEngine.Debug.LogError(GetOutput(text, par));
}
return !val;
}
private static string GetOutput(string s, params object[] par)
{
var output = "";
if (par == null || par.Length == 0)
{
output = s;
}
else
{
output = string.Format(s, par);
}
return "[" + GetTime() + "]" + " : " + output;
}
private static string GetColorOutput(string color, string s, params object[] par)
{
var output = "";
if (par == null || par.Length == 0)
{
output = s;
}
else
{
output = string.Format(s, par);
}
return "<color=" + color + ">" + "[" + GetTime() + "]" + " : " + output + "</color>";
}
private static string GetTime()
{
return DateTime.Now.ToShortTimeString();
}
}
}