/// <summary> /// Adds a new log item to the log. /// </summary> /// <param name="severity">The severity of the log message.</param> /// <param name="message">The description of this log item.</param> public void Log(LogSeverity severity, string message) { LogItem logItem = new LogItem(severity, message); lock (this) { LogList.Add(logItem); if (ShouldShow(severity)) { VisibleList.Add(logItem); } } // Write warnings (or worse) to the console. if (severity >= LogSeverity.Warning) { Console.WriteLine(""); Console.WriteLine(logItem.ToString()); } }
/// <summary> /// Updates the currently displayed log items if there are changes to the visible list. /// </summary> public void UpdateVisible() { if (VisibleSetDirty) { lock (this) { if (VisibleSetDirty) { //% Using Linq Select may be quicker here? VisibleList.Clear(); foreach (LogItem logItem in LogList) { if (ShouldShow(logItem.Severity)) { VisibleList.Add(logItem); } } VisibleSetDirty = false; } } } }