private void SetLogMessageDetail(LogMessageItem logMsgItem) { // Store the text to avoid editing without settings the control // as readonly... kind of ugly trick... if (logMsgItem == null) { logDetailTextBox.Text = string.Empty; PopulateExceptions(null); OpenSourceFile(null, 0); } else { StringBuilder sb = new StringBuilder(); sb.Append(logMsgItem.GetMessageDetails()); if (UserSettings.Instance.ShowMsgDetailsProperties) { // Append properties foreach (KeyValuePair <string, string> kvp in logMsgItem.Message.Properties) { sb.AppendFormat("{0} = {1}{2}", kvp.Key, kvp.Value, Environment.NewLine); } } // Append exception tbExceptions.Text = string.Empty; if (UserSettings.Instance.ShowMsgDetailsException && !String.IsNullOrEmpty(logMsgItem.Message.ExceptionString)) { //sb.AppendLine(logMsgItem.Message.ExceptionString); if (!string.IsNullOrEmpty(logMsgItem.Message.ExceptionString)) { PopulateExceptions(logMsgItem.Message.ExceptionString); } } logDetailTextBox.ForeColor = logMsgItem.Message.Level.Color; logDetailTextBox.Rtf = sb.ToString(); OpenSourceFile(logMsgItem.Message.SourceFileName, logMsgItem.Message.SourceFileLineNr); } }
private void logListView_SelectedIndexChanged(object sender, EventArgs e) { RemovedLoggerHighlight(); LogMessageItem logMsgItem = null; if (logListView.SelectedItems.Count > 0) { logMsgItem = logListView.SelectedItems[0].Tag as LogMessageItem; } SetLogMessageDetail(logMsgItem); // Highlight Logger in the Tree View if ((logMsgItem != null) && (UserSettings.Instance.HighlightLogger)) { logMsgItem.Parent.Highlight = true; _lastHighlightedLogger = logMsgItem.Parent; } }
private void SetLogMessageDetail(LogMessageItem logMsgItem) { // Store the text to avoid editing without settings the control // as readonly... kind of ugly trick... if (logMsgItem == null) { _msgDetailText = string.Empty; } else { var sb = new StringBuilder(); if (UserSettings.Instance.ShowMsgDetailsProperties) { // Append properties foreach (var kvp in logMsgItem.Message.Properties) { sb.AppendFormat("{0} = {1}{2}", kvp.Key, kvp.Value, Environment.NewLine); } } // Append message sb.AppendLine(logMsgItem.Message.Message.Replace("\n", "\r\n")); // Append exception if (UserSettings.Instance.ShowMsgDetailsException && !string.IsNullOrEmpty(logMsgItem.Message.ExceptionString)) { sb.AppendLine(logMsgItem.Message.ExceptionString); } _msgDetailText = sb.ToString(); logDetailTextBox.ForeColor = logMsgItem.Message.Level.Color; } logDetailTextBox.Text = _msgDetailText; }
private void SetLogMessageDetail(LogMessageItem logMsgItem) { // Store the text to avoid editing without settings the control // as readonly... kind of ugly trick... if (logMsgItem == null) { logDetailTextBox.Text = string.Empty; PopulateExceptions(null); OpenSourceFile(null, 0); } else { var sb = new StringBuilder(); sb.Append(logMsgItem.GetMessageDetails()); // Removing trailing '}' char sb.Remove(sb.Length - 1, 1); if (_configuration.ShowMsgDetailsProperties) // Append properties { foreach (var kvp in logMsgItem.Message.Properties) { sb.AppendFormat("{0} = {1}{2}", kvp.Key, kvp.Value, "\\line\n"); } } // Append exception tbExceptions.Text = string.Empty; if (_configuration.ShowMsgDetailsException && !string.IsNullOrEmpty(logMsgItem.Message.ExceptionString)) //sb.AppendLine(logMsgItem.Message.ExceptionString); { if (!string.IsNullOrEmpty(logMsgItem.Message.ExceptionString)) { PopulateExceptions(logMsgItem.Message.ExceptionString); } } // Closing rtf document sb.Append('}'); var rtf = sb.ToString(); // Since rtf only support 7-bit text encoding, we need to escape non-ASCII chars rtf = Regex.Replace(rtf, "[^\x00-\x7F]", m => $@"\u{(short)m.Value[0]}{m.Value[0]}"); logDetailTextBox.ForeColor = logMsgItem.Message.Level.Color; if (_configuration.UseMsgDetailsRtf) { logDetailTextBox.Rtf = rtf; } else { logDetailTextBox.Text = sb.ToString(); } OpenSourceFile(logMsgItem.Message.SourceFileName, logMsgItem.Message.SourceFileLineNr); } }