Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created April 25, 2014 10:11
Show Gist options
  • Select an option

  • Save baba-s/11284462 to your computer and use it in GitHub Desktop.

Select an option

Save baba-s/11284462 to your computer and use it in GitHub Desktop.
using System;
using UnityEngine;
/// <summary>
/// ログに関する汎用関数を管理するクラス
/// </summary>
public static partial class DebugUtils
{
/// <summary>
/// ログを出力します
/// </summary>
public static void Log(string format, params object[] args)
{
Debug.Log(string.Format(format, args));
}
/// <summary>
/// 指定された条件が false の場合はログを出力します
/// </summary>
public static void Log(bool condition, string format, params object[] args)
{
if (condition)
{
return;
}
Log(format, args);
}
/// <summary>
/// 警告ログを出力します
/// </summary>
public static void Warning(string format, params object[] args)
{
Debug.LogWarning(string.Format(format, args));
}
/// <summary>
/// 指定された条件が false の場合は警告ログを出力します
/// </summary>
public static void Warning(bool condition, string format, params object[] args)
{
if (condition)
{
return;
}
Warning(format, args);
}
/// <summary>
/// エラーログを出力します
/// </summary>
public static void Error(string format, params object[] args)
{
Debug.LogError(string.Format(format, args));
}
/// <summary>
/// 指定された条件が false の場合はエラーログを出力します
/// </summary>
public static void Error(bool condition, string format, params object[] args)
{
if (condition)
{
return;
}
Error(format, args);
}
/// <summary>
/// 指定された条件が false の場合は例外を出力します
/// </summary>
public static void Assert(bool condition)
{
if (condition)
{
return;
}
throw new Exception();
}
/// <summary>
/// 指定された条件が false の場合は例外を出力します
/// </summary>
public static void Assert(bool condition, string format, params object[] args)
{
if (condition)
{
return;
}
throw new Exception(string.Format(format, args));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment