AssetsLog.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Diagnostics;
  2. namespace XGame.Framework.Asset
  3. {
  4. internal static class AssetsLog
  5. {
  6. private static bool _isOpen = true;
  7. private static readonly string _head = "[Assets]";
  8. [Conditional(MacroDefine.UNITY_EDITOR)]
  9. #if !PROFILER
  10. [Conditional(MacroDefine.DEBUG)]
  11. #endif
  12. public static void Debug(string format, params object[] args)
  13. {
  14. if (_isOpen)
  15. {
  16. Log.Debug($"{_head} {Format(format, args)}");
  17. }
  18. }
  19. [Conditional(MacroDefine.UNITY_EDITOR), Conditional(MacroDefine.DEBUG), Conditional(MacroDefine.PROFILER), Conditional(MacroDefine.FINAL_RELEASE)]
  20. public static void Info(string format, params object[] args)
  21. {
  22. if (_isOpen)
  23. {
  24. Log.Info($"{_head} {Format(format, args)}");
  25. }
  26. }
  27. [Conditional(MacroDefine.UNITY_EDITOR), Conditional(MacroDefine.DEBUG), Conditional(MacroDefine.PROFILER)]
  28. public static void Warn(string format, params object[] args)
  29. {
  30. if (_isOpen)
  31. {
  32. Log.Warn($"{_head} {Format(format, args)}");
  33. }
  34. }
  35. public static void Error(string format, params object[] args)
  36. {
  37. Log.Error($"{_head} {Format(format, args)}");
  38. }
  39. public static void Exception(System.Exception exception)
  40. {
  41. Log.Exception(_head, exception);
  42. }
  43. private static string Format(string format, params object[] args)
  44. {
  45. if (args == null || args.Length <= 0)
  46. return format;
  47. else
  48. return string.Format(format, args);
  49. }
  50. }
  51. }