/// <summary> /// Log with an entry and only text /// </summary> /// <param name="entryType">The type to log</param> /// <param name="sourceName">The name of the source of the log</param> /// <param name="sourceGuid">The guid of the source of the log</param> /// <param name="text">The text string</param> public void Log(LogEntryType entryType, string sourceName, Guid sourceGuid, string text) { if ((LogEntryAdded != null) && (text != null)) { if ((LogLevel & entryType) == entryType) { LogEntryAdded.Invoke(this, new LogEntryAddedEventArgs(entryType, text, null, sourceName ?? "Unknown", sourceGuid)); } } }
/// <summary> /// Log a formatted entry /// </summary> /// <param name="entryType">The type to log</param> /// <param name="sourceName">The name of the source of the log</param> /// <param name="sourceGuid">The guid of the source of the log</param> /// <param name="format">The format string</param> /// <param name="args">Format arguments</param> public void Log(LogEntryType entryType, string sourceName, Guid sourceGuid, string format, params object[] args) { if (LogEntryAdded != null) { if ((LogLevel & entryType) == entryType) { LogEntryAdded.Invoke(this, new LogEntryAddedEventArgs(entryType, String.Format(format, args), null, sourceName, sourceGuid)); } } }
public override void WriteLine(string message) { var logEntry = new LogEntry() { Source = _name, Severity = _severity, Text = _lineBuffer + message, TimeStamp = DateTime.Now }; _lineBuffer = null; LogEntryAdded?.Invoke(logEntry); }
/// <summary> /// Log an exception /// </summary> /// <param name="type">Type of log entry</param> /// <param name="sourceGuid">Guid of the source</param> /// <param name="sourceName">Name of the source</param> /// <param name="ex">The exception to log</param> public void LogException(LogEntryType type, string sourceName, Guid sourceGuid, Exception ex) { if (LogEntryAdded != null) { if ((LogLevel & type) == type) { string message = ex.Message; // Unwrap a few common wrapped messages if ((ex is TargetInvocationException) || (ex is AuthenticationException)) { if (ex.InnerException != null) { message = ex.InnerException.Message; } } LogEntryAdded.Invoke(this, new LogEntryAddedEventArgs(type, message, ex, sourceName, sourceGuid)); } } }
protected static void OnLogEntryAdded(string logEntry) => LogEntryAdded?.Invoke(null, logEntry);
private void OnLogEntryAdded(LogEntry entry) { LogEntryAdded?.Invoke(this, new LogEntryAddedEventArgs(entry)); }
public void Report(LogEntry entry) { _logger.Log(entry); LogEntryAdded?.Invoke(this, new LogEntryAddedEventArgs(entry)); }
public static void Log(LogEntry entry) { LogEntryAdded?.Invoke(entry); entries.Add(entry); }
/// <summary> /// Invoke the LogEntryAdded event /// </summary> /// <param name="e"></param> protected virtual void OnLogEntryAdded(LogEntryAddedEventArgs e) { LogEntryAdded?.Invoke(null, e); }