void IRenderEvents.Render(SystemEvent e) { if (filter.Exclude(e)) return; lock (bufferedItems) { bufferedItems.Add(CreateListViewItem(e)); } }
public void Bind(SystemEvent e) { Verify.NotNull(e, "e"); // Message tab messageText.Text = e.Message; // Details tab messageId.Text = e.MessageId.ToString(CultureInfo.CurrentUICulture); level.Text = e.Level.ToString(); source.Text = e.Source; timestamp.Text = e.Timestamp.ToString("yyyy-MM-dd HH:mm:ss,fff"); process.Text = e.ProcessName + " (" + e.ProcessId + ")"; thread.Text = e.Thread; username.Text = e.Username; message.Text = e.Message; // Raw tab rawText.Text = e.RawMessage.Value; }
public void Render(SystemEvent e) { if (filter.Exclude(e)) return; Console.ForegroundColor = timestampColor; Console.BackgroundColor = defaultBackColor; Console.Write(String.Format("{0:HH:mm:ss,fff} ", e.Timestamp)); Console.BackgroundColor = Settings.GetBackeColor(e.Level); Console.ForegroundColor = Settings.GetForeColor(e.Level); stringBuilder.Clear(); stringBuilder.AppendFormat("[{0}] ", GetProcessId(e)); stringBuilder.AppendFormat("{0} ", GetProcessName(e)); stringBuilder.AppendFormat("[{0}] ", GetThread(e)); stringBuilder.AppendFormat("{0} ", GetSource(e)); stringBuilder.AppendFormat("[{0}] ", GetLevel(e)); stringBuilder.Append(e.Message); Console.WriteLine(stringBuilder.ToString()); }
private static Char GetLevel(SystemEvent e) { switch (e.Level) { case SystemEventLevel.Fatal: return 'F'; case SystemEventLevel.Error: return 'E'; case SystemEventLevel.Warning: return 'W'; case SystemEventLevel.Information: return 'I'; case SystemEventLevel.Debug: return 'D'; default: return 'T'; } }
private String GetThread(SystemEvent e) { var value = e.Thread ?? String.Empty; MaxThreadLength = Math.Max(MaxThreadLength, value.Length); return value.PadRight(MaxThreadLength, ' '); }
private String GetSource(SystemEvent e) { var value = e.Source ?? String.Empty; MaxSourceLength = Math.Max(MaxSourceLength, value.Length); return value.PadRight(MaxSourceLength, ' '); }
private String GetProcessName(SystemEvent e) { var value = e.ProcessName ?? String.Empty; MaxProcessNameLength = Math.Max(MaxProcessNameLength, value.Length); return value.PadRight(MaxProcessNameLength, ' '); }
private String GetProcessId(SystemEvent e) { var value = e.ProcessId.ToString(CultureInfo.InvariantCulture); MaxProcessIdLength = Math.Max(MaxProcessIdLength, value.Length); return value.PadLeft(MaxProcessIdLength, ' '); }
private ListViewItem CreateListViewItem(SystemEvent e) { return new ListViewItem(new[] { e.MessageId.ToString(CultureInfo.InvariantCulture), e.Timestamp.ToString("HH:mm:ss,fff"), e.Level.ToString(), e.ProcessId.ToString(CultureInfo.InvariantCulture), e.ProcessName, e.Thread, e.Source, e.Username, e.Message }) { Tag = e, ForeColor = GetForegroundColor(e.Level), BackColor = GetBackgroundColor(e.Level) }; }