diff --git a/Assets/1_Script/Common/Logger.cs b/Assets/1_Script/Common/Logger.cs new file mode 100644 index 0000000..50eb71c --- /dev/null +++ b/Assets/1_Script/Common/Logger.cs @@ -0,0 +1,53 @@ +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using UnityEngine; + +/// +/// Debug.Log을 좀 더 편하게 사용하기 위한 헬퍼 클래스입니다. +/// +public static class Logger +{ + public enum Level { Debug, Info, Warning, Error } + + // 릴리즈 빌드에서 불필요한 스택트레이스 끄기 + static Logger() + { +#if !UNITY_EDITOR && !DEVELOPMENT_BUILD + Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None); + Application.SetStackTraceLogType(LogType.Warning,StackTraceLogType.None); + Application.SetStackTraceLogType(LogType.Error, StackTraceLogType.ScriptOnly); +#endif + } + + // 에디터/개발 빌드에서만 컴파일됨 → 릴리즈에선 이 호출 자체가 사라집니다 + [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")] + public static void LogDebug(object message, UnityEngine.Object context = null) => LogInternal(Level.Debug, message, context); + + [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")] + public static void LogInfo(object message, UnityEngine.Object context = null) => LogInternal(Level.Info, message, context); + + [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")] + public static void LogWarning(object message, UnityEngine.Object context = null) => LogInternal(Level.Warning, message, context); + + // 에러는 항상 남겨둡니다 + public static void LogError(object message, UnityEngine.Object context = null) => LogInternal(Level.Error, message, context); + + static void LogInternal(Level level, object message, UnityEngine.Object context = null) + { + switch (level) + { + case Level.Debug: + case Level.Info: + UnityEngine.Debug.Log(message, context); + break; + case Level.Warning: + UnityEngine.Debug.LogWarning(message, context); + break; + case Level.Error: + UnityEngine.Debug.LogError(message, context); + break; + } + } +} \ No newline at end of file diff --git a/Assets/1_Script/Common/Logger.cs.meta b/Assets/1_Script/Common/Logger.cs.meta new file mode 100644 index 0000000..9f12225 --- /dev/null +++ b/Assets/1_Script/Common/Logger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 49e767187741d7a44a8d5a4997eeb9fe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: