示例#1
0
        void RadegastAppender_Log(object sender, LogEventArgs e)
        {
            if (!IsHandleCreated) return;

            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(() => RadegastAppender_Log(sender, e)));
                return;
            }

            rtbLog.SelectionColor = Color.FromKnownColor(KnownColor.WindowText);
            rtbLog.AppendText(string.Format("{0} [", e.LogEntry.TimeStamp.ToString("HH:mm:ss")));

            if (e.LogEntry.Level == Level.Error)
            {
                rtbLog.SelectionColor = Color.Red;
            }
            else if (e.LogEntry.Level == Level.Warn)
            {
                rtbLog.SelectionColor = Color.Yellow;
            }
            else if (e.LogEntry.Level == Level.Info)
            {
                rtbLog.SelectionColor = Color.Green;
            }
            else
            {
                rtbLog.SelectionColor = Color.Gray;
            }

            rtbLog.AppendText(e.LogEntry.Level.Name);
            rtbLog.SelectionColor = Color.FromKnownColor(KnownColor.WindowText);
            rtbLog.AppendText(string.Format("]: - {0}{1}", e.LogEntry.MessageObject.ToString(), Environment.NewLine));
        }
示例#2
0
 protected static void OnLog(object sender, LogEventArgs e)
 {
     EventHandler<LogEventArgs> handler = m_Log;
     if (handler != null)
         try { handler(sender, e); }
         catch { }
 }