릴리즈 빌드 시 전용 로깅 스크립트를 사용하면 Debug.Log( )를 일괄 제어할 수 있다.
로그를 사용하지 않으려면 #define USE_LOGS를 주석 처리하면 된다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | #define USE_LOG using UnityEngine; public sealed class Logger { #if USE_LOG public const string ENABLE_LOGS = "ENABLE_LOG"; #endif [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void Log(object message) { Debug.Log(message); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void Log(object message, Object context) { Debug.Log(message, context); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogFormat(string message, params object[] args) { Debug.LogFormat(message, args); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogFormat(Object context, string message, params object[] args) { Debug.LogFormat(context, message, args); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogWarning(object message) { Debug.LogWarning(message); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogWarning(object message, Object context) { Debug.LogWarning(message, context); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogWarningFormat(string message, params object[] args) { Debug.LogWarningFormat(message, args); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogWarningFormat(Object context, string message, params object[] args) { Debug.LogWarningFormat(context, message, args); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogError(object message) { Debug.LogError(message); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogError(object message, Object context) { Debug.LogError(message, context); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogErrorFormat(string message, params object[] args) { Debug.LogErrorFormat(message, args); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogErrorFormat(Object context, string message, params object[] args) { Debug.LogErrorFormat(context, message, args); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogException(System.Exception exception) { Debug.LogException(exception); } [System.Diagnostics.Conditional(ENABLE_LOGS)] public static void LogException(System.Exception exception, Object context) { Debug.LogException(exception, context); } } | cs |
'게임 개발 > Unity3D' 카테고리의 다른 글
[Unity | 유니티] Manager vs. Controller vs. Handler (1) | 2019.03.11 |
---|---|
[Unity | 유니티] 데이터를 CSV 파일로 추출하기 (0) | 2018.12.13 |
[Unity | 유니티] 커스텀 정렬 알고리즘 만들기 (0) | 2018.11.21 |
[Unity | 유니티] Serializable Class 활용하기 (30) | 2018.11.21 |
[Unity | 유니티] 특정 디렉토리에서 프리팹 또는 파일 로드하기 (0) | 2018.11.15 |