public void AddLogMessage(string message, MessageSeverity severity) { WriteLine(message); // Raise an event to any listeners that want to so something else with the message LogMessageArgs e = new LogMessageArgs(message, severity); LogMessage(this, e); }
private void AddMessageToListView(ListView lvwTargetListView, LogMessageArgs e) { ListViewItem lvi = new ListViewItem(); Color rowColour; lvi.Text = e.Message; switch (e.Severity) { case Log.MessageSeverity.Error: rowColour = Color.Red; break; case Log.MessageSeverity.Warning: rowColour = Color.Orange; break; case Log.MessageSeverity.Info: rowColour = Color.Green; break; default: rowColour = Color.Black; break; } lvi.ForeColor = rowColour; if (lvwTargetListView.InvokeRequired) { lvwTargetListView.Invoke(new Action(() => lvwTargetListView.Items.Add(lvi))); } else { lvwTargetListView.Items.Add(lvi); } }
private void OnSQLLogMessage(object sender, LogMessageArgs e) { AddMessageToListView(lvwFixSQL, e); }
private void OnStatusLogMessage(object sender, LogMessageArgs e) { AddMessageToListView(lvwStatus, e); }