#define BARRACUDA_LOG_ENABLED
using System;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Unity.Barracuda
{
///
/// Barracuda debug logging utility
///
public class D
{
///
/// Warning stack trace collection enabling flag
///
public static bool warningStackTraceEnabled = Application.isEditor;
///
/// Error stack trace collection enabling flag
///
public static bool errorStackTraceEnabled = true;
///
/// Debug log stack trace collection enabling flag
///
public static bool logStackTraceEnabled = false;
///
/// Warning logging enabled flag
///
public static bool warningEnabled = true;
///
/// Error logging enabled flag
///
public static bool errorEnabled = true;
///
/// Debug logging enabled flag
///
public static bool logEnabled = true;
#if BARRACUDA_LOG_ENABLED
///
/// Log warning
///
/// message
public static void LogWarning(object message)
{
if (!warningEnabled)
return;
if (!warningStackTraceEnabled)
{
try
{
var oldConfig = Application.GetStackTraceLogType(LogType.Warning);
Application.SetStackTraceLogType(LogType.Warning, StackTraceLogType.None);
UnityEngine.Debug.LogWarning(message);
Application.SetStackTraceLogType(LogType.Warning, oldConfig);
}
catch (Exception)
{
UnityEngine.Debug.LogWarning(message);
}
}
else
{
UnityEngine.Debug.LogWarning(message);
}
}
///
/// Log warning
///
/// message
/// context
public static void LogWarning(object message, Object context)
{
if (!warningEnabled)
return;
if (!warningStackTraceEnabled)
{
try
{
var oldConfig = Application.GetStackTraceLogType(LogType.Warning);
Application.SetStackTraceLogType(LogType.Warning, StackTraceLogType.None);
UnityEngine.Debug.LogWarning(message, context);
Application.SetStackTraceLogType(LogType.Warning, oldConfig);
}
catch (Exception)
{
UnityEngine.Debug.LogWarning(message, context);
}
}
else
{
UnityEngine.Debug.LogWarning(message, context);
}
}
///
/// Log error
///
/// message
public static void LogError(object message)
{
if (!errorEnabled)
return;
if (!errorStackTraceEnabled)
{
try
{
var oldConfig = Application.GetStackTraceLogType(LogType.Warning);
Application.SetStackTraceLogType(LogType.Error, StackTraceLogType.None);
UnityEngine.Debug.LogError(message);
Application.SetStackTraceLogType(LogType.Error, oldConfig);
}
catch (Exception)
{
UnityEngine.Debug.LogError(message);
}
}
else
{
UnityEngine.Debug.LogError(message);
}
}
///
/// Log error
///
/// message
/// context
public static void LogError(object message, Object context)
{
if (!errorEnabled)
return;
if (!errorStackTraceEnabled)
{
try
{
var oldConfig = Application.GetStackTraceLogType(LogType.Warning);
Application.SetStackTraceLogType(LogType.Error, StackTraceLogType.None);
UnityEngine.Debug.LogError(message, context);
Application.SetStackTraceLogType(LogType.Error, oldConfig);
}
catch (Exception)
{
UnityEngine.Debug.LogError(message, context);
}
}
else
{
UnityEngine.Debug.LogError(message, context);
}
}
///
/// Log debug info
///
/// message
public static void Log(object message)
{
if (!logEnabled)
return;
if (!logStackTraceEnabled)
{
try
{
var oldConfig = Application.GetStackTraceLogType(LogType.Warning);
Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
UnityEngine.Debug.Log(message);
Application.SetStackTraceLogType(LogType.Log, oldConfig);
}
catch (Exception)
{
UnityEngine.Debug.Log(message);
}
}
else
{
UnityEngine.Debug.Log(message);
}
}
///
/// Log debug info
///
/// message
/// context
public static void Log(object message, Object context)
{
if (!logEnabled)
return;
if (!logStackTraceEnabled)
{
try
{
var oldConfig = Application.GetStackTraceLogType(LogType.Warning);
Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
UnityEngine.Debug.Log(message, context);
Application.SetStackTraceLogType(LogType.Log, oldConfig);
}
catch (Exception)
{
UnityEngine.Debug.Log(message, context);
}
}
else
{
UnityEngine.Debug.Log(message, context);
}
}
#else
public static void LogWarning(object message)
{
}
public static void LogWarning(object message, Object context)
{
}
public static void LogError(object message)
{
}
public static void LogError(object message, Object context)
{
}
public static void Log(object message)
{
}
public static void Log(object message, Object context)
{
}
#endif
}
internal class Debug : D
{
}
}