using System;
using System.Linq;
using UnityEngine;
namespace Unity.XR.CoreUtils
{
///
/// Utility methods for logging.
///
///
/// These methods mirror the standard log methods, but do not log
/// anything if tests are being run via command line (using `-runTests`).
///
/// See [Running tests from the command line](https://docs.unity3d.com/Packages/com.unity.test-framework@latest?subfolder=/manual/reference-command-line.html)
/// for information about running tests.
///
public static class XRLoggingUtils
{
static readonly bool k_DontLogAnything;
static XRLoggingUtils()
{
k_DontLogAnything = Environment.GetCommandLineArgs().Contains("-runTests");
}
///
/// Same as , but does not print anything if tests are being run.
///
/// Log message for display.
/// Object to which the message applies.
public static void Log(string message, UnityEngine.Object context = null)
{
if (!k_DontLogAnything)
Debug.Log(message, context);
}
///
/// Same as , but does not print anything if tests are being run.
///
/// Warning message for display.
/// Object to which the message applies.
public static void LogWarning(string message, UnityEngine.Object context = null)
{
if (!k_DontLogAnything)
Debug.LogWarning(message, context);
}
///
/// Same as , but does not print anything if tests are being run.
///
/// Error message for display.
/// Object to which the message applies.
public static void LogError(string message, UnityEngine.Object context = null)
{
if (!k_DontLogAnything)
Debug.LogError(message, context);
}
///
/// Same as , but does not print anything if tests are being run.
///
/// Runtime Exception.
/// Object to which the message applies.
public static void LogException(Exception exception, UnityEngine.Object context = null)
{
if (!k_DontLogAnything)
Debug.LogException(exception, context);
}
}
}