using System; using JD.Kernel.Structs; namespace JD.LogService { /// /// An informational message. /// [Serializable] public class Message : LogEvent { #region Variables private MessageImportance m_importance = MessageImportance.Normal; #endregion #region Constructors public Message() : base(LogCategory.Message) {} public Message(string message) : this() { Message = message; } public Message(string message, params object[] args) : this(FormatString(message, args)) { } [Obsolete("Log events are now mutable. Use the basic Message(string) constructor and set the rest of the properties.")] // 2011.01 public Message(FileLocation origin, string message) : this(message) { Origin = origin; } #endregion #region Properties /// /// Relative importance of the message. /// public MessageImportance Importance { get { return m_importance; } set { m_importance = value; } } #endregion #region Methods public override string ToString() { return $"[Message: Text={Message}, Importance={Importance}]"; } /// /// Returns the message in canonical format. /// public override string ToCanonicalString() { if (m_importance != MessageImportance.Normal) { return $"{m_importance}:{Message}"; } return Message; } #endregion #region Static Creation [Obsolete("Log events are now mutable. Use the basic Message(string, object[]) constructor.")] // 2011.01 public static Message MessageFormated(string message, params object[] args) { return new Message(message, args); } #endregion } }