BuildLog.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. namespace XGame.Editor.Build
  3. {
  4. public static class BuildLog
  5. {
  6. public static void Log(string msg)
  7. {
  8. UnityEngine.Debug.Log(Convert(msg));
  9. }
  10. public static void Log(string format, params object[] args)
  11. {
  12. UnityEngine.Debug.Log(Convert(Format(format, args)));
  13. }
  14. public static void Warn(string msg)
  15. {
  16. UnityEngine.Debug.LogWarning(Convert(msg));
  17. }
  18. public static void Warn(string format, params object[] args)
  19. {
  20. UnityEngine.Debug.LogWarning(Convert(Format(format, args)));
  21. }
  22. public static void Error(string msg)
  23. {
  24. UnityEngine.Debug.LogError(Convert(msg));
  25. }
  26. public static void Error(string format, params object[] args)
  27. {
  28. UnityEngine.Debug.LogError(Convert(Format(format, args)));
  29. }
  30. public static void Exception(Exception e)
  31. {
  32. UnityEngine.Debug.LogError(Convert($"Exception Message:{e.Message}"));
  33. UnityEngine.Debug.LogException(e);
  34. }
  35. private static string Convert(string msg)
  36. {
  37. return $"[XBuild][{DateTime.Now}] {msg}";
  38. }
  39. private static string Format(string format, params object[] args)
  40. {
  41. if (args == null || args.Length <= 0)
  42. return format;
  43. else
  44. return string.Format(format, args);
  45. }
  46. }
  47. }