72 lines
1.3 KiB
C#
Raw Normal View History

namespace QuantumUNET.Logging
2020-12-23 13:48:31 +00:00
{
public static class QLog
{
public const int DebugType = 0;
public const int LogType = 1;
public const int WarningType = 2;
public const int ErrorType = 3;
public const int FatalErrorType = 4;
2020-12-23 13:48:31 +00:00
2021-02-15 10:58:21 +00:00
private static int _currentLog = 2;
private static bool _logDebug => _currentLog <= 0;
private static bool _logLog => _currentLog <= 1;
private static bool _logWarning => _currentLog <= 2;
private static bool _logError => _currentLog <= 3;
private static bool _logFatal => _currentLog <= 4;
2020-12-23 13:48:31 +00:00
public static void SetLogType(int level)
=> _currentLog = level;
2020-12-23 13:48:31 +00:00
public static void Debug(string message)
2020-12-23 13:48:31 +00:00
{
2021-03-09 16:43:41 +00:00
if (!_logDebug)
2020-12-23 13:48:31 +00:00
{
return;
}
2021-06-18 22:39:21 +01:00
UnityEngine.Debug.Log($"DEBUG : {message}");
2020-12-23 13:48:31 +00:00
}
public static void Log(string message)
{
2021-03-09 16:43:41 +00:00
if (!_logLog)
2020-12-23 13:48:31 +00:00
{
return;
}
2021-06-18 22:39:21 +01:00
UnityEngine.Debug.Log($"LOG : {message}");
2020-12-23 13:48:31 +00:00
}
public static void Warning(string message)
2020-12-23 13:48:31 +00:00
{
2021-03-09 16:43:41 +00:00
if (!_logWarning)
2020-12-23 13:48:31 +00:00
{
return;
}
2021-06-18 22:39:21 +01:00
UnityEngine.Debug.LogWarning($"WARN : {message}");
2020-12-23 13:48:31 +00:00
}
public static void Error(string message)
2020-12-23 13:48:31 +00:00
{
2021-03-09 16:43:41 +00:00
if (!_logError)
2020-12-23 13:48:31 +00:00
{
return;
}
2021-06-18 22:39:21 +01:00
UnityEngine.Debug.LogError($"ERROR : {message}");
2020-12-23 13:48:31 +00:00
}
public static void FatalError(string message)
2020-12-23 13:48:31 +00:00
{
2021-03-09 16:43:41 +00:00
if (!_logFatal)
2020-12-23 13:48:31 +00:00
{
return;
}
2021-06-18 22:39:21 +01:00
UnityEngine.Debug.LogError($"FATAL : {message}");
2020-12-23 13:48:31 +00:00
}
}
}