private void Add(LogEntrySeverity severity, string source, string message, Exception exception) { LogEntry logEntry; lock (_logEntries) { _id += 1L; logEntry = new LogEntry(_id, _dateTimeService.Now, Environment.CurrentManagedThreadId, severity, source, message, exception?.ToString()); EnqueueLogEntry(logEntry, _logEntries, LogHistorySize); } if (severity == LogEntrySeverity.Warning) { lock (_warningLogEntries) { EnqueueLogEntry(logEntry, _warningLogEntries, LogWarningHistorySize); } } else if (severity == LogEntrySeverity.Error) { lock (_errorLogEntries) { EnqueueLogEntry(logEntry, _errorLogEntries, LogErrorHistorySize); } } LogEntryPublished?.Invoke(this, new LogEntryPublishedEventArgs(logEntry)); Log.ForwardPublishedLogEntry(logEntry); if (!Debugger.IsAttached) { return; } Debug.WriteLine($"[{logEntry.Severity}] [{logEntry.Source}] [{logEntry.ThreadId}]: {message}"); }
public static void ForwardPublishedLogEntry(LogEntry logEntry) { LogEntryPublished?.Invoke(null, new LogEntryPublishedEventArgs(logEntry)); }