ConsoleEntry.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using UnityEngine;
  3. namespace SRDebugger.Services
  4. {
  5. public class ConsoleEntry
  6. {
  7. public ConsoleEntry()
  8. {
  9. }
  10. public ConsoleEntry(ConsoleEntry other)
  11. {
  12. this.Message = other.Message;
  13. this.StackTrace = other.StackTrace;
  14. this.LogType = other.LogType;
  15. this.Count = other.Count;
  16. }
  17. public string MessagePreview
  18. {
  19. get
  20. {
  21. if (this._messagePreview != null)
  22. {
  23. return this._messagePreview;
  24. }
  25. if (string.IsNullOrEmpty(this.Message))
  26. {
  27. return string.Empty;
  28. }
  29. this._messagePreview = this.Message.Split(new char[]
  30. {
  31. '\n'
  32. })[0];
  33. this._messagePreview = this._messagePreview.Substring(0, Mathf.Min(this._messagePreview.Length, 180));
  34. return this._messagePreview;
  35. }
  36. }
  37. public string StackTracePreview
  38. {
  39. get
  40. {
  41. if (this._stackTracePreview != null)
  42. {
  43. return this._stackTracePreview;
  44. }
  45. if (string.IsNullOrEmpty(this.StackTrace))
  46. {
  47. return string.Empty;
  48. }
  49. this._stackTracePreview = this.StackTrace.Split(new char[]
  50. {
  51. '\n'
  52. })[0];
  53. this._stackTracePreview = this._stackTracePreview.Substring(0, Mathf.Min(this._stackTracePreview.Length, 120));
  54. return this._stackTracePreview;
  55. }
  56. }
  57. public bool Matches(ConsoleEntry other)
  58. {
  59. return !object.ReferenceEquals(null, other) && (object.ReferenceEquals(this, other) || (string.Equals(this.Message, other.Message) && string.Equals(this.StackTrace, other.StackTrace) && this.LogType == other.LogType));
  60. }
  61. private const int MessagePreviewLength = 180;
  62. private const int StackTracePreviewLength = 120;
  63. private string _messagePreview;
  64. private string _stackTracePreview;
  65. public int Count = 1;
  66. public LogType LogType;
  67. public string Message;
  68. public string StackTrace;
  69. }
  70. }