using System; namespace Unosquare.Swan { /// /// Event arguments representing the message that is logged /// on to the terminal. Use the properties to forward the data to /// your logger of choice. /// /// public class LogMessageReceivedEventArgs : EventArgs { /// /// Initializes a new instance of the class. /// /// The sequence. /// Type of the message. /// The UTC date. /// The source. /// The message. /// The extended data. /// Name of the caller member. /// The caller file path. /// The caller line number. public LogMessageReceivedEventArgs( UInt64 sequence, LogMessageType messageType, DateTime utcDate, String source, String message, Object extendedData, String callerMemberName, String callerFilePath, Int32 callerLineNumber) { this.Sequence = sequence; this.MessageType = messageType; this.UtcDate = utcDate; this.Source = source; this.Message = message; this.CallerMemberName = callerMemberName; this.CallerFilePath = callerFilePath; this.CallerLineNumber = callerLineNumber; this.ExtendedData = extendedData; } /// /// Gets logging message sequence. /// /// /// The sequence. /// public UInt64 Sequence { get; } /// /// Gets the type of the message. /// It can be a combination as the enumeration is a set of bitwise flags. /// /// /// The type of the message. /// public LogMessageType MessageType { get; } /// /// Gets the UTC date at which the event at which the message was logged. /// /// /// The UTC date. /// public DateTime UtcDate { get; } /// /// Gets the name of the source where the logging message /// came from. This can come empty if the logger did not set it. /// /// /// The source. /// public String Source { get; } /// /// Gets the body of the message. /// /// /// The message. /// public String Message { get; } /// /// Gets the name of the caller member. /// /// /// The name of the caller member. /// public String CallerMemberName { get; } /// /// Gets the caller file path. /// /// /// The caller file path. /// public String CallerFilePath { get; } /// /// Gets the caller line number. /// /// /// The caller line number. /// public Int32 CallerLineNumber { get; } /// /// Gets an object representing extended data. /// It could be an exception or anything else. /// /// /// The extended data. /// public Object ExtendedData { get; } /// /// Gets the Extended Data properties cast as an Exception (if possible) /// Otherwise, it return null. /// /// /// The exception. /// public Exception Exception => this.ExtendedData as Exception; } /// /// Event arguments representing a message logged and about to be /// displayed on the terminal (console). Set the CancelOutput property in the /// event handler to prevent the terminal from displaying the message. /// /// public class LogMessageDisplayingEventArgs : LogMessageReceivedEventArgs { /// /// Initializes a new instance of the class. /// /// The instance containing the event data. public LogMessageDisplayingEventArgs(LogMessageReceivedEventArgs data) : base( data.Sequence, data.MessageType, data.UtcDate, data.Source, data.Message, data.ExtendedData, data.CallerMemberName, data.CallerFilePath, data.CallerLineNumber) => this.CancelOutput = false; /// /// Gets or sets a value indicating whether the displaying of the /// logging message should be canceled. /// /// /// true if [cancel output]; otherwise, false. /// public Boolean CancelOutput { get; set; } } }