LogEventArgs.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*===============================================================================
  2. * Change history
  3. * When Who TaskId Comment
  4. * ---------- ------ ------ ------------------------------------
  5. * 2006-08-08 RMa Added LogType to the log event args.
  6. * 2006-05-17 RMa Created
  7. *
  8. ---------------------------------------------------------------------------------*/
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Text;
  12. namespace Wayne.Lib.StateEngine
  13. {
  14. /// <summary>
  15. /// Categorizes the log entries in the OnLog event from the State machine.
  16. /// </summary>
  17. public enum LogType
  18. {
  19. /// <summary>
  20. /// Logging when a state entry is performed.
  21. /// </summary>
  22. Enter,
  23. /// <summary>
  24. /// Logging when a state exit is performed.
  25. /// </summary>
  26. Exit,
  27. /// <summary>
  28. /// Logging when an event is sent into a state for handling.
  29. /// </summary>
  30. HandleEvent,
  31. /// <summary>
  32. /// Logging when an exception has been unhandled in the user code.
  33. /// </summary>
  34. Error,
  35. /// <summary>
  36. /// Misc. debug logging.
  37. /// </summary>
  38. Debug,
  39. /// <summary>
  40. /// Warnings about unhandled transitions.
  41. /// </summary>
  42. UnhandledTransition,
  43. }
  44. /// <summary>
  45. /// The Log Event args is used to carry log strings when logging internally in the
  46. /// state machine. Applications can hook on the StateMachine.OnLog event in order to
  47. /// catch loggins from the inner workings of the statemachine.
  48. /// </summary>
  49. public sealed class LogEventArgs : EventArgs
  50. {
  51. #region Fields
  52. LogType logType;
  53. string logText;
  54. #endregion
  55. #region Construction
  56. /// <summary>
  57. /// Initializes a new instance of the LogEventArgs class.
  58. /// </summary>
  59. /// <param name="logType">Category of this log entry.</param>
  60. /// <param name="logText">Text to be logged.</param>
  61. internal LogEventArgs(LogType logType, string logText)
  62. {
  63. this.logText = logText;
  64. this.logType = logType;
  65. }
  66. #endregion
  67. #region Properties
  68. /// <summary>
  69. /// The log text from the Statemachine.
  70. /// </summary>
  71. public string LogText
  72. {
  73. get { return logText; }
  74. }
  75. /// <summary>
  76. /// Category of the log entry.
  77. /// </summary>
  78. public LogType LogType
  79. {
  80. get { return logType; }
  81. }
  82. #endregion
  83. }
  84. }