示例#1
0
        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;
        }
示例#3
0
        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());
        }
示例#4
0
 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';
     }
 }
示例#5
0
        private String GetThread(SystemEvent e)
        {
            var value = e.Thread ?? String.Empty;

            MaxThreadLength = Math.Max(MaxThreadLength, value.Length);

            return value.PadRight(MaxThreadLength, ' ');
        }
示例#6
0
        private String GetSource(SystemEvent e)
        {
            var value = e.Source ?? String.Empty;

            MaxSourceLength = Math.Max(MaxSourceLength, value.Length);

            return value.PadRight(MaxSourceLength, ' ');
        }
示例#7
0
        private String GetProcessName(SystemEvent e)
        {
            var value = e.ProcessName ?? String.Empty;

            MaxProcessNameLength = Math.Max(MaxProcessNameLength, value.Length);

            return value.PadRight(MaxProcessNameLength, ' ');
        }
示例#8
0
        private String GetProcessId(SystemEvent e)
        {
            var value = e.ProcessId.ToString(CultureInfo.InvariantCulture);

            MaxProcessIdLength = Math.Max(MaxProcessIdLength, value.Length);

            return value.PadLeft(MaxProcessIdLength, ' ');
        }
示例#9
0
 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) };
 }