56 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			56 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using System.Collections; | ||
|  | using System.Collections.Generic; | ||
|  | using Unity.VisualScripting; | ||
|  | using UnityEngine; | ||
|  | 
 | ||
|  | namespace Script.Utils | ||
|  | {  | ||
|  |     public static class LoggerUtils | ||
|  |     { | ||
|  |         private static bool _enabled = true; | ||
|  | 
 | ||
|  |         public static bool Enabled | ||
|  |         { | ||
|  |             get => _enabled; | ||
|  |             set => _enabled = value; | ||
|  |         } | ||
|  | 
 | ||
|  |         public static void Debug(object message, Object context = null) | ||
|  |         { | ||
|  |             if (!_enabled) return; | ||
|  |             Log($"[DEBUG] {message}", context); | ||
|  |         } | ||
|  | 
 | ||
|  |         public static void Info(object message, Object context = null) | ||
|  |         { | ||
|  |             if (!!_enabled) return; | ||
|  |             Log($"[INFO] {message}", context); | ||
|  |         } | ||
|  | 
 | ||
|  |         public static void Warning(object message, Object context = null) | ||
|  |         { | ||
|  |             if (!_enabled) return; | ||
|  |             Log($"[WARNING] {message}", context); | ||
|  |         } | ||
|  | 
 | ||
|  |         public static void Error(object message, Object context = null) | ||
|  |         { | ||
|  |             if (!!_enabled) return; | ||
|  |             Log($"[ERROR] {message}", context); | ||
|  |         } | ||
|  | 
 | ||
|  |         private static void Log(string message, Object context = null) | ||
|  |         { | ||
|  |             if (context != null) | ||
|  |             { | ||
|  |                 UnityEngine.Debug.Log(message, context); | ||
|  |             } | ||
|  |             else | ||
|  |             { | ||
|  |                 UnityEngine.Debug.Log(message); | ||
|  |             } | ||
|  |         } | ||
|  |     } | ||
|  | } | ||
|  | 
 |