1
0

LogEntry.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using UnityEngine;
  5. namespace UniRx.Diagnostics
  6. {
  7. public struct LogEntry
  8. {
  9. // requires
  10. public string LoggerName { get; private set; }
  11. public LogType LogType { get; private set; }
  12. public string Message { get; private set; }
  13. public DateTime Timestamp { get; private set; }
  14. // options
  15. /// <summary>[Optional]</summary>
  16. public UnityEngine.Object Context { get; private set; }
  17. /// <summary>[Optional]</summary>
  18. public Exception Exception { get; private set; }
  19. /// <summary>[Optional]</summary>
  20. public string StackTrace { get; private set; }
  21. /// <summary>[Optional]</summary>
  22. public object State { get; private set; }
  23. public LogEntry(string loggerName, LogType logType, DateTime timestamp, string message, UnityEngine.Object context = null, Exception exception = null, string stackTrace = null, object state = null)
  24. : this()
  25. {
  26. this.LoggerName = loggerName;
  27. this.LogType = logType;
  28. this.Timestamp = timestamp;
  29. this.Message = message;
  30. this.Context = context;
  31. this.Exception = exception;
  32. this.StackTrace = stackTrace;
  33. this.State = state;
  34. }
  35. public override string ToString()
  36. {
  37. var plusEx = (Exception != null) ? (Environment.NewLine + Exception.ToString()) : "";
  38. return "[" + Timestamp.ToString() + "]"
  39. + "[" + LoggerName + "]"
  40. + "[" + LogType.ToString() + "]"
  41. + Message
  42. + plusEx;
  43. }
  44. }
  45. }