webgl 빌드 시 log4net 제거

This commit is contained in:
logonkhi
2025-11-11 13:51:23 +09:00
parent ef0c7546dc
commit 293e7b5cef
9 changed files with 183 additions and 41 deletions

View File

@@ -1,3 +1,4 @@
#if !UNITY_WEBGL || UNITY_EDITOR
using log4net;
using log4net.Appender;
using log4net.Core;
@@ -10,7 +11,7 @@ using System;
using System.IO;
using UnityEngine;
namespace Assets.Scripts.UVC.Log
namespace UVC.Log
{
/// <summary>
/// xml 설정에서 AppData\LocalLow\Company Name\Product Name\ 접근 할 수 없어서 사용.
@@ -122,3 +123,4 @@ namespace Assets.Scripts.UVC.Log
}
}
#endif

View File

@@ -1,5 +1,5 @@
#nullable enable
#nullable enable
#if !UNITY_WEBGL || UNITY_EDITOR
using log4net.Appender;
using log4net.Core;
using SQLite4Unity3d;
@@ -177,3 +177,4 @@ namespace UVC.Log
}
}
}
#endif

View File

@@ -1,11 +1,12 @@
#nullable enable
#nullable enable
#if !UNITY_WEBGL || UNITY_EDITOR
using log4net;
using log4net.Appender;
using log4net.Core;
using log4net.Filter;
using log4net.Layout;
using log4net.Repository.Hierarchy;
#endif
using System;
using System.Diagnostics;
using System.IO;
@@ -15,12 +16,15 @@ namespace UVC.Log
{
public static class ULog
{
#if !UNITY_WEBGL || UNITY_EDITOR
private static readonly ILog logger = LogManager.GetLogger(typeof(ULog));
#endif
private static readonly bool useUnityDebug = true; // Unity Debug 사용 여부
static ULog()
{
#if !UNITY_WEBGL || UNITY_EDITOR
if (!useUnityDebug)
{
// unity runtime 일때
@@ -35,11 +39,13 @@ namespace UVC.Log
//FileConfigure();
}
}
#endif
}
public static void Debug(string msg)
{
#if !UNITY_WEBGL || UNITY_EDITOR
if (logger.IsDebugEnabled)
{
if (useUnityDebug)
@@ -57,10 +63,14 @@ namespace UVC.Log
logger.Debug(type.Name + "." + name + " [line " + lineNumber + "] " + msg);
}
}
#else
UnityEngine.Debug.Log(msg);
#endif
}
public static void Info(string msg)
{
#if !UNITY_WEBGL || UNITY_EDITOR
if (logger.IsInfoEnabled)
{
if (useUnityDebug)
@@ -78,11 +88,15 @@ namespace UVC.Log
logger.Info(type.Name + "." + name + " [line " + lineNumber + "] " + msg);
}
}
#else
UnityEngine.Debug.Log(msg);
#endif
}
public static void Warning(string msg, Exception? ex = null)
{
#if !UNITY_WEBGL || UNITY_EDITOR
if (logger.IsWarnEnabled)
{
if (useUnityDebug)
@@ -100,10 +114,14 @@ namespace UVC.Log
logger.Warn(type.Name + "." + name + " [line " + lineNumber + "] " + msg, ex);
}
}
#else
UnityEngine.Debug.LogWarning(msg);
#endif
}
public static void Error(string msg, Exception? ex = null)
{
#if !UNITY_WEBGL || UNITY_EDITOR
if (logger.IsErrorEnabled)
{
if (useUnityDebug)
@@ -121,10 +139,15 @@ namespace UVC.Log
logger.Error(type.Name + "." + name + " [line " + lineNumber + "] " + msg, ex);
}
}
#else
if (ex != null) UnityEngine.Debug.LogError($"{msg}\n{ex}");
else UnityEngine.Debug.LogError(msg);
#endif
}
public static void Fatal(string msg, Exception? ex = null)
{
#if !UNITY_WEBGL || UNITY_EDITOR
if (logger.IsFatalEnabled)
{
if (useUnityDebug)
@@ -142,9 +165,13 @@ namespace UVC.Log
logger.Fatal(type.Name + "." + name + " [line " + lineNumber + "] " + msg, ex);
}
}
#else
if (ex != null) UnityEngine.Debug.LogError($"{msg}\n{ex}");
else UnityEngine.Debug.LogError(msg);
#endif
}
#if !UNITY_WEBGL || UNITY_EDITOR
/// <summary>
/// log4net 파일 설정을 구성합니다.
/// Assets/Resources/log4net.editor.xml log4net.runtime.xml 파일로 구성하였기에 사용안함.
@@ -201,5 +228,6 @@ namespace UVC.Log
}
#endif
}
}