LogEventArgs.cs 2.6 KB

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