リポジトリ
使用例
using UniDebugLogger; using UnityEngine; public class Example : MonoBehaviour { private void Awake() { IDebugLogger logger; logger = DefaultDebugLogger.Instance; logger.Log( "Log" ); logger.Log( "Log", gameObject ); logger.LogWarning( "LogWarning" ); logger.LogWarning( "LogWarning", gameObject ); logger.LogError( "LogError" ); logger.LogError( "LogError", gameObject ); logger.LogFormat( "LogFormat {0} / {1}", 1, 2 ); logger.LogFormat( gameObject, "LogFormat {0} / {1}", 1, 2 ); logger.LogWarningFormat( "LogWarningFormat {0} / {1}", 1, 2 ); logger.LogWarningFormat( gameObject, "LogWarningFormat {0} / {1}", 1, 2 ); logger.LogErrorFormat( "LogErrorFormat {0} / {1}", 1, 2 ); logger.LogErrorFormat( gameObject, "LogErrorFormat {0} / {1}", 1, 2 ); logger = TaggedDebugLogger.Create( "タイトル" ); logger.Log( "Log" ); logger.Log( "Log", gameObject ); logger.LogWarning( "LogWarning" ); logger.LogWarning( "LogWarning", gameObject ); logger.LogError( "LogError" ); logger.LogError( "LogError", gameObject ); logger.LogFormat( "LogFormat {0} / {1}", 1, 2 ); logger.LogFormat( gameObject, "LogFormat {0} / {1}", 1, 2 ); logger.LogWarningFormat( "LogWarningFormat {0} / {1}", 1, 2 ); logger.LogWarningFormat( gameObject, "LogWarningFormat {0} / {1}", 1, 2 ); logger.LogErrorFormat( "LogErrorFormat {0} / {1}", 1, 2 ); logger.LogErrorFormat( gameObject, "LogErrorFormat {0} / {1}", 1, 2 ); logger = NullDebugLogger.Instance; logger.Log( "Log" ); logger.Log( "Log", gameObject ); logger.LogWarning( "LogWarning" ); logger.LogWarning( "LogWarning", gameObject ); logger.LogError( "LogError" ); logger.LogError( "LogError", gameObject ); logger.LogFormat( "LogFormat {0} / {1}", 1, 2 ); logger.LogFormat( gameObject, "LogFormat {0} / {1}", 1, 2 ); logger.LogWarningFormat( "LogWarningFormat {0} / {1}", 1, 2 ); logger.LogWarningFormat( gameObject, "LogWarningFormat {0} / {1}", 1, 2 ); logger.LogErrorFormat( "LogErrorFormat {0} / {1}", 1, 2 ); logger.LogErrorFormat( gameObject, "LogErrorFormat {0} / {1}", 1, 2 ); } }
補足
DISABLE_UNI_DEBUG_LOGGERシンボルを定義することですべてのデバッグログを無効化できる