Logger.cs 934 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace Agora.Util
  4. {
  5. public class Logger
  6. {
  7. Text text;
  8. public Logger(Text text)
  9. {
  10. this.text = text;
  11. }
  12. public void UpdateLog(string logMessage)
  13. {
  14. return;
  15. Debug.Log(logMessage);
  16. string srcLogMessage = text.text;
  17. if (srcLogMessage.Length > 400)
  18. {
  19. srcLogMessage = srcLogMessage.Substring(srcLogMessage.Length - 50);
  20. }
  21. srcLogMessage += "\r\n \r\n";
  22. srcLogMessage += logMessage;
  23. text.text = srcLogMessage;
  24. }
  25. public bool DebugAssert(bool condition, string message)
  26. {
  27. if (!condition)
  28. {
  29. UpdateLog(message);
  30. return false;
  31. }
  32. Debug.Assert(condition, message);
  33. return true;
  34. }
  35. }
  36. }