123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using System;
- using System.Diagnostics.CodeAnalysis;
- using JetBrains.Annotations;
- #if (UNITY_2019_4_OR_NEWER)
- using UnityEngine;
- #endif
- namespace SingularityGroup.HotReload {
- public static class Log {
- [SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Global")]
- public static LogLevel minLevel = LogLevel.Info;
- /// <summary>
- /// Tag every log so that users know which logs came from Hot Reload
- /// </summary>
- private const string TAG = "[HotReload] ";
- public static void Debug(string message) {
- if (minLevel <= LogLevel.Debug) {
- #if (UNITY_2019_4_OR_NEWER)
- UnityEngine.Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "{0}{1}", TAG, message);
- #else
- UnityEngine.Debug.Log(TAG + message);
- #endif
- }
- }
- [StringFormatMethod("message")]
- public static void Debug(string message, params object[] args) {
- if (minLevel <= LogLevel.Debug) {
- #if (UNITY_2019_4_OR_NEWER)
- UnityEngine.Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, TAG + message, args);
- #else
- UnityEngine.Debug.LogFormat(TAG + message, args);
- #endif
- }
- }
-
- public static void Info(string message) {
- if (minLevel <= LogLevel.Info) {
- #if (UNITY_2019_4_OR_NEWER)
- UnityEngine.Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "{0}{1}", TAG, message);
- #else
- UnityEngine.Debug.Log(TAG + message);
- #endif
- }
- }
- [StringFormatMethod("message")]
- public static void Info(string message, params object[] args) {
- if (minLevel <= LogLevel.Info) {
- #if (UNITY_2019_4_OR_NEWER)
- UnityEngine.Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, TAG + message, args);
- #else
- UnityEngine.Debug.LogFormat(TAG + message, args);
- #endif
- }
- }
- public static void Warning(string message) {
- if (minLevel <= LogLevel.Warning) {
- #if (UNITY_2019_4_OR_NEWER)
- UnityEngine.Debug.LogFormat(LogType.Warning, LogOption.NoStacktrace, null, "{0}{1}", TAG, message);
- #else
- UnityEngine.Debug.LogWarning(TAG + message);
- #endif
- }
- }
-
- [StringFormatMethod("message")]
- public static void Warning(string message, params object[] args) {
- if (minLevel <= LogLevel.Warning) {
- #if (UNITY_2019_4_OR_NEWER)
- UnityEngine.Debug.LogFormat(LogType.Warning, LogOption.NoStacktrace, null, TAG + message, args);
- #else
- UnityEngine.Debug.LogWarningFormat(TAG + message, args);
- #endif
- }
- }
- public static void Error(string message) {
- if (minLevel <= LogLevel.Error) {
- #if (UNITY_2019_4_OR_NEWER)
- UnityEngine.Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, "{0}{1}", TAG, message);
- #else
- UnityEngine.Debug.LogError(TAG + message);
- #endif
- }
- }
-
- [StringFormatMethod("message")]
- public static void Error(string message, params object[] args) {
- if (minLevel <= LogLevel.Error) {
- #if (UNITY_2019_4_OR_NEWER)
- UnityEngine.Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, TAG + message, args);
- #else
- UnityEngine.Debug.LogErrorFormat(TAG + message, args);
- #endif
- }
- }
-
- public static void Exception(Exception exception) {
- if (minLevel <= LogLevel.Exception) {
- UnityEngine.Debug.LogException(exception);
- }
- }
- }
- }
|