/// <summary> /// Selects the given <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> o select</param> public bool SelectLogMessage(LogMessage message) { LogMessageLog4Net logMessage = message as LogMessageLog4Net; try { this.SuspendDrawing(); if (logMessage != null) { txtDataLogger.Text = logMessage.Logger; txtDataLevel.Text = logMessage.Level.ToString(); txtDataDateTime.Text = logMessage.Timestamp.AddMilliseconds(logMessage.TimeShiftOffset).ToString(Settings.Default.TimestampFormat); txtDataThread.Text = logMessage.Thread; if (logMessage.TimeShiftOffset != 0) { txtDataDateTime.Text += string.Format( Resources.strLoggerDetailsCtrlOffset , logMessage.TimeShiftOffset); } // Replace all known new line character combinations with the .net one. txtDataMessage.Text = Regex.Replace( logMessage.Message , @"\r(?!\n)|(?<!\r)\n" , Environment.NewLine); StringBuilder dataBuilder = new StringBuilder(); dataBuilder.AppendLine(!string.IsNullOrEmpty(logMessage.Location.MethodName) ? logMessage.Location.MethodName : string.Empty); dataBuilder.AppendLine(!string.IsNullOrEmpty(logMessage.Location.ClassName) ? logMessage.Location.ClassName : string.Empty); dataBuilder.AppendLine(!string.IsNullOrEmpty(logMessage.Location.FileName) ? logMessage.Location.FileName : string.Empty); txtDataLocation.Text = dataBuilder.ToString().Trim(); if (logMessage.CustomProperties == null || logMessage.CustomProperties.Count == 0) { txtDataProperties.Text = string.Empty; } else { dataBuilder = new StringBuilder(); foreach (KeyValuePair<string, string> customData in logMessage.CustomProperties) { dataBuilder.AppendFormat("{0}: {1}{2}", customData.Key, customData.Value, Environment.NewLine); } txtDataProperties.Text = dataBuilder.ToString(); } } else { txtDataLogger.Text = string.Empty; txtDataLevel.Text = message != null ? message.Level.ToString() : string.Empty; txtDataDateTime.Text = message != null ? message.Timestamp.ToString(Settings.Default.TimestampFormat) : string.Empty; txtDataThread.Text = string.Empty; txtDataMessage.Text = message != null ? message.Message.Trim() : string.Empty; txtDataProperties.Text = string.Empty; } pbxCopyLogger.Visible = !string.IsNullOrEmpty(txtDataLogger.Text); pbxCopyLevel.Visible = !string.IsNullOrEmpty(txtDataLevel.Text); pbxCopyThread.Visible = !string.IsNullOrEmpty(txtDataThread.Text); pbxCopyDateTime.Visible = !string.IsNullOrEmpty(txtDataDateTime.Text); pbxCopyMessage.Visible = !string.IsNullOrEmpty(txtDataMessage.Text); pbxCopyLocation.Visible = !string.IsNullOrEmpty(txtDataLocation.Text); pbxCopyProperties.Visible = !string.IsNullOrEmpty(txtDataProperties.Text); } finally { txtDataMessage.AdjustHeightToContent(); txtDataProperties.AdjustHeightToContent(); this.ResumeDrawing(); } return true; }
/// <summary> /// Selects the given <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> o select</param> public bool SelectLogMessage(LogMessage message) { if (message != null && mFilteredLogMessages.Contains(message)) { return SelectLogMessage(mFilteredLogMessages.IndexOf(message)); } return false; }
/// <summary> /// Selects the given <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> o select</param> /// <returns><c>True</c> if the given <paramref name="message"/> was selected successfully, otherwise <c>false</c>.</returns> public bool SelectLogMessage(LogMessage message) { // Nothing to do here. return false; }
/// <summary> /// Determines whether the given <paramref name="message"/> is filtered out, or not. /// </summary> /// <param name="message">The <see cref="LogMessage"/> to check.</param> /// <returns><c>True</c> if the given <see cref="LogMessage"/> is filtered, or not.</returns> private bool IsMessageFiltered(LogMessage message) { if (message == null) { return true; } if (mLogFilterToApply != null) { foreach (LogFilter filter in mLogFilterToApply) { if (filter.IsActive && !filter.Match(message)) { return true; } } } return false; }
/// <summary> /// Removes the given <paramref name="message"/> from the bookmarks. /// </summary> /// <param name="message">The <see cref="LogMessage"/> to remove from the bookmarks.</param> public void RemoveBookmark(LogMessage message) { if (message != null && mBookmarks.Contains(message)) { mBookmarks.Remove(message); } dtgLogMessages.Invalidate(); foreach (IBookmarkObserver observer in mBookmarkObserver) { observer.BookmarksChanged(); } }
/// <summary> /// Synchronizes the tree to the specified <see cref="LogMessage"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> to synchronize the tree with.</param> public void SynchronizeTree(LogMessage message) { if (mLoggerTree != null) { ((FrmLogTree)mLoggerTree).SynchronizeTree(message); } }
/// <summary> /// Selects the given <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> o select</param> /// <returns><c>True</c> if the given <paramref name="message"/> was selected successfully, otherwise <c>false</c>.</returns> public bool SelectLogMessage(LogMessage message) { if (message == null || mBookmarkProvider == null) { return false; } tsbNextBookmark.Enabled = dgvBookmarks.SelectedRows.Count > 0 && !dgvBookmarks.Rows[dgvBookmarks.RowCount - 1].Selected; tsbPreviousBookmark.Enabled = dgvBookmarks.SelectedRows.Count > 0 && !dgvBookmarks.Rows[0].Selected; return true; }
/// <summary> /// Synchronizes the tree to the specified <see cref="LogMessage"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> to synchronize the tree with.</param> public void SynchronizeTree(LogMessage message) { if (message != null && !string.IsNullOrEmpty(message.Logger)) { TreeNode syncNode = GetNodeByFullPath(tvLoggerTree.Nodes[0], string.Format( "{0}{1}{2}" , Properties.Resources.strLoggerRoot , tvLoggerTree.PathSeparator , message.Logger)); if (syncNode != null) { tvLoggerTree.SelectedNode = syncNode; } } }
/// <summary> /// Handles the given <paramref name="logMsg"/> <see cref="LogMessage"/>. /// </summary> /// <param name="logMsg">The <see cref="LogMessage"/> to handle.</param> public void HandleMessage(LogMessage logMsg) { mLogMessageLock.EnterWriteLock(); try { // Always set the current timeshift value. logMsg.TimeShiftOffset = mTimeShiftValue; mLogMessages.Add(logMsg); if (Settings.Default.MaxLogMessages > 0 && mLogMessages.Count > Settings.Default.MaxLogMessages) { // Remove from the first posotion on. mLogMessages.RemoveRange( 0 , mLogMessages.Count - Settings.Default.MaxLogMessages); } } finally { mLogMessageLock.ExitWriteLock(); } }
/// <summary> /// Selects the given <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> o select</param> public bool SelectLogMessage(LogMessage message) { // There is no select message support for the logger tree. return true; }
/// <summary> /// Selects the given <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> to select</param> /// <returns><c>True</c> if the given <paramref name="message"/> was selected successfully, otherwise <c>false</c>.</returns> public bool SelectLogMessage(LogMessage message) { return true; }
/// <summary> /// Creates a new instance of the <see cref="LogMessageSelectedEventArgs"/> class. /// </summary> /// <param name="message">The selected <see cref="LogMessage"/>.</param> public LogMessageSelectedEventArgs(LogMessage message) { Message = message; }
/// <summary> /// Selects the given <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> o select</param> public bool SelectLogMessage(LogMessage message) { LogMessageSyslog logMessage = message as LogMessageSyslog; try { this.SuspendDrawing(); if (logMessage != null) { txtDataNumber.Text = logMessage.Index.ToString(); txtDataSeverity.Text = logMessage.Level.ToString(); txtDataLocalMachineTime.Text = logMessage.LocalTimestamp.AddMilliseconds(logMessage.TimeShiftOffset).ToString(Settings.Default.TimestampFormat); txtDataTime.Text = logMessage.Timestamp.ToString(Settings.Default.TimestampFormat); txtDataFacility.Text = logMessage.LogFacility.ToString(); txtDataSender.Text = logMessage.Logger; if (logMessage.TimeShiftOffset != 0) { txtDataLocalMachineTime.Text += string.Format( Resources.strLoggerDetailsCtrlOffset , logMessage.TimeShiftOffset); } // Replace all known new line character combinations with the .net one. txtDataMessage.Text = Regex.Replace( logMessage.Message , @"\r(?!\n)|(?<!\r)\n" , Environment.NewLine); } else { txtDataNumber.Text = message != null ? message.Index.ToString() : string.Empty; txtDataSeverity.Text = message != null ? message.Level.ToString() : string.Empty; txtDataLocalMachineTime.Text = string.Empty; txtDataTime.Text = message != null ? message.Timestamp.ToString(Settings.Default.TimestampFormat) : string.Empty; txtDataFacility.Text = string.Empty; txtDataSender.Text = message != null ? message.Logger : string.Empty; txtDataMessage.Text = message != null ? message.Message.Trim() : string.Empty; } pbxCopyNumber.Visible = !string.IsNullOrEmpty(txtDataNumber.Text); pbxCopySeverity.Visible = !string.IsNullOrEmpty(txtDataSeverity.Text); pbxCopyTime.Visible = !string.IsNullOrEmpty(txtDataTime.Text); pbxCopyLocalMachineTime.Visible = !string.IsNullOrEmpty(txtDataLocalMachineTime.Text); pbxCopyFacility.Visible = !string.IsNullOrEmpty(txtDataFacility.Text); pbxCopySender.Visible = !string.IsNullOrEmpty(txtDataSender.Text); pbxCopyMessage.Visible = !string.IsNullOrEmpty(txtDataMessage.Text); } finally { txtDataFacility.AdjustHeightToContent(); txtDataMessage.AdjustHeightToContent(); this.ResumeDrawing(); } return true; }
/// <summary> /// Selects the given <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="LogMessage"/> o select</param> public bool SelectLogMessage(LogMessage message) { return mPresenter != null && mPresenter.SelectLogMessage(message); }