Class LogPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, EventBatchListener, Profileable, SettingsListener

public class LogPanel extends DockablePanel implements EventBatchListener, Profileable
A LogPanel provides a view to a collection of LoggingEvents.

As events are received, the keywords in the 'tab identifier' application preference are replaced with the values from the received event. The main application uses this expression to route received LoggingEvents to individual LogPanels which match each event's resolved expression.

The LogPanel's capabilities can be broken up into four areas:
  • toolbar - provides 'find' and 'refine focus' features
  • logger tree - displays a tree of the logger hierarchy, which can be used to filter the display
  • table - displays the events which pass the filtering rules
  • detail panel - displays information about the currently selected event
Here is a complete list of LogPanel's capabilities:
  • display selected LoggingEvent row number and total LoggingEvent count
  • pause or unpause reception of LoggingEvents
  • configure, load and save column settings (displayed columns, order, width)
  • configure, load and save color rules filter displayed LoggingEvents based on the logger tree settings
  • filter displayed LoggingEvents based on a 'refine focus' expression (evaluates only those LoggingEvents which pass the logger tree filter
  • colorize LoggingEvents based on expressions
  • hide, show and configure the detail pane and tooltip
  • configure the formatting of the logger, level and timestamp fields
  • dock or undock
  • table displays first line of exception, but when cell is clicked, a popup opens to display the full stack trace
  • find
  • scroll to bottom
  • sort
  • provide a context menu which can be used to build color or display expressions
  • hide or show the logger tree
  • toggle the container storing the LoggingEvents to use either a CyclicBuffer (defaults to max size of 5000, but configurable through CHAINSAW_CAPACITY system property) or ArrayList (no max size)
  • use the mouse context menu to 'best-fit' columns, define display expression filters based on mouse location and access other capabilities
See Also:
  • Field Details

    • TIMESTAMP_DATE_FORMAT

      private static final DateFormat TIMESTAMP_DATE_FORMAT
    • DEFAULT_DETAIL_SPLIT_LOCATION

      private static final double DEFAULT_DETAIL_SPLIT_LOCATION
      See Also:
    • DEFAULT_LOG_TREE_SPLIT_LOCATION

      private static final double DEFAULT_LOG_TREE_SPLIT_LOCATION
      See Also:
    • identifier

      private final String identifier
    • statusBar

      private final ChainsawStatusBar statusBar
    • logPanelPreferencesFrame

      private final JFrame logPanelPreferencesFrame
    • colorPanel

      private ColorPanel colorPanel
    • colorFrame

      private final JFrame colorFrame
    • undockedFrame

      private final JFrame undockedFrame
    • externalPanel

      private final DockablePanel externalPanel
    • dockingAction

      private final Action dockingAction
    • undockedToolbar

      private final JToolBar undockedToolbar
    • table

      private final JSortTable table
    • renderer

      private final TableColorizingRenderer renderer
    • tableModel

      private final EventContainer tableModel
    • detail

      private final JEditorPane detail
    • lowerPanel

      private final JSplitPane lowerPanel
    • detailPaneUpdater

      private final LogPanel.DetailPaneUpdater detailPaneUpdater
    • detailPanel

      private final JPanel detailPanel
    • nameTreeAndMainPanelSplit

      private final JSplitPane nameTreeAndMainPanelSplit
    • logTreePanel

      private final LoggerNameTreePanel logTreePanel
    • preferenceModel

      private final LogPanelPreferenceModel preferenceModel
    • applicationPreferenceModel

      private ApplicationPreferenceModel applicationPreferenceModel
    • logPanelPreferencesPanel

      private final LogPanelPreferencePanel logPanelPreferencesPanel
    • filterModel

      private final FilterModel filterModel
    • colorizer

      private final RuleColorizer colorizer
    • tableRuleMediator

      private final RuleMediator tableRuleMediator
    • searchRuleMediator

      private final RuleMediator searchRuleMediator
    • detailLayout

      private final EventDetailLayout detailLayout
    • lastLogTreePanelSplitLocation

      private double lastLogTreePanelSplitLocation
    • currentPoint

      private Point currentPoint
    • currentTable

      private JTable currentTable
    • paused

      private boolean paused
    • findRule

      private org.apache.log4j.rule.Rule findRule
    • currentFindRuleText

      private String currentFindRuleText
    • findMarkerRule

      private org.apache.log4j.rule.Rule findMarkerRule
    • dividerSize

      private final int dividerSize
    • TABLE_COLUMN_ORDER

      static final String TABLE_COLUMN_ORDER
      See Also:
    • TABLE_COLUMN_WIDTHS

      static final String TABLE_COLUMN_WIDTHS
      See Also:
    • COLORS_EXTENSION

      static final String COLORS_EXTENSION
      See Also:
    • LOG_PANEL_SERIALIZATION_VERSION_NUMBER

      private static final int LOG_PANEL_SERIALIZATION_VERSION_NUMBER
      See Also:
    • previousLastIndex

      private int previousLastIndex
    • logger

      private final org.apache.log4j.Logger logger
    • filterCombo

      private LogPanel.AutoFilterComboBox filterCombo
    • findCombo

      private LogPanel.AutoFilterComboBox findCombo
    • eventsPane

      private JScrollPane eventsPane
    • currentSearchMatchCount

      private int currentSearchMatchCount
    • clearTableExpressionRule

      private org.apache.log4j.rule.Rule clearTableExpressionRule
    • lowerPanelDividerLocation

      private int lowerPanelDividerLocation
    • searchModel

      private EventContainer searchModel
    • searchTable

      private final JSortTable searchTable
    • searchRenderer

      private TableColorizingRenderer searchRenderer
    • mainToggleToolTips

      private LogPanel.ToggleToolTips mainToggleToolTips
    • searchToggleToolTips

      private LogPanel.ToggleToolTips searchToggleToolTips
    • detailPane

      private JScrollPane detailPane
    • searchPane

      private JScrollPane searchPane
    • markerCellEditor

      private TableCellEditor markerCellEditor
    • detailToolbar

      private JToolBar detailToolbar
    • searchResultsDisplayed

      private boolean searchResultsDisplayed
    • colorizedEventAndSearchMatchThumbnail

      private LogPanel.ColorizedEventAndSearchMatchThumbnail colorizedEventAndSearchMatchThumbnail
    • eventTimeDeltaMatchThumbnail

      private LogPanel.EventTimeDeltaMatchThumbnail eventTimeDeltaMatchThumbnail
    • isDetailPanelVisible

      private boolean isDetailPanelVisible
  • Constructor Details

    • LogPanel

      public LogPanel(ChainsawStatusBar statusBar, String identifier, int cyclicBufferSize, Map<String,RuleColorizer> allColorizers, ApplicationPreferenceModel applicationPreferenceModel)
      Creates a new LogPanel object. If a LogPanel with this identifier has been loaded previously, reload settings saved on last exit.
      Parameters:
      statusBar - shared status bar, provided by main application
      identifier - used to load and save settings
  • Method Details

    • getValueOf

      private String getValueOf(int row, int column)
    • getFindNextAction

      private Action getFindNextAction()
    • getFindPreviousAction

      private Action getFindPreviousAction()
    • buildCombo

      private void buildCombo(LogPanel.AutoFilterComboBox combo, boolean isFiltering, LogPanel.AutoFilterComboBox.AutoFilterComboBoxModel otherModel)
    • isScrollToBottom

      public boolean isScrollToBottom()
      Accessor
      Returns:
      scrollToBottom
    • setRefineFocusText

      public void setRefineFocusText(String refineFocusText)
    • getRefineFocusText

      public String getRefineFocusText()
    • toggleScrollToBottom

      public void toggleScrollToBottom()
      Mutator
    • scrollToBottom

      private void scrollToBottom()
    • scrollToTop

      public void scrollToTop()
    • getNamespace

      public String getNamespace()
      Accessor
      Specified by:
      getNamespace in interface Profileable
      Returns:
      namespace
      See Also:
    • getInterestedIdentifier

      public String getInterestedIdentifier()
      Accessor
      Specified by:
      getInterestedIdentifier in interface EventBatchListener
      Returns:
      identifier
      See Also:
    • receiveEventBatch

      public void receiveEventBatch(String ident, List<org.apache.log4j.spi.LoggingEvent> events)
      Process events associated with the identifier. Currently assumes it only receives events which share this LogPanel's identifier
      Specified by:
      receiveEventBatch in interface EventBatchListener
      Parameters:
      ident - identifier shared by events
      events - list of LoggingEvent objects
    • loadSettings

      public void loadSettings(LoadSettingsEvent event)
      Load settings from the panel preference model
      Specified by:
      loadSettings in interface SettingsListener
      Parameters:
      event -
      See Also:
    • saveSettings

      public void saveSettings(SaveSettingsEvent event)
      Save preferences to the panel preference model
      Specified by:
      saveSettings in interface SettingsListener
      Parameters:
      event -
      See Also:
    • buildXStreamForLogPanelPreference

      private com.thoughtworks.xstream.XStream buildXStreamForLogPanelPreference()
    • showPreferences

      void showPreferences()
      Display the panel preferences frame
    • centerAndSetVisible

      public static void centerAndSetVisible(Window window)
    • showColorPreferences

      void showColorPreferences()
      Display the color rule frame
    • toggleDetailVisible

      void toggleDetailVisible()
      Toggle panel preference for detail visibility on or off
    • isDetailVisible

      boolean isDetailVisible()
      Accessor
      Returns:
      detail visibility flag
    • isSearchResultsVisible

      boolean isSearchResultsVisible()
    • toggleLogTreeVisible

      void toggleLogTreeVisible()
      Toggle panel preference for logger tree visibility on or off
    • isLogTreeVisible

      boolean isLogTreeVisible()
      Accessor
      Returns:
      logger tree visibility flag
    • getEvents

      List getEvents()
      Return all events
      Returns:
      list of LoggingEvents
    • getFilteredEvents

      List getFilteredEvents()
      Return the events that are visible with the current filter applied
      Returns:
      list of LoggingEvents
    • getMatchingEvents

      List<LoggingEventWrapper> getMatchingEvents(org.apache.log4j.rule.Rule rule)
    • clearEvents

      void clearEvents()
      Remove all events
    • getIdentifier

      String getIdentifier()
      Accessor
      Returns:
      identifier
    • undock

      void undock()
      Undocks this DockablePanel by removing the panel from the LogUI window and placing it inside it's own JFrame.
    • addEventCountListener

      void addEventCountListener(EventCountListener l)
      Add an eventCountListener
      Parameters:
      l -
    • isPaused

      boolean isPaused()
      Accessor
      Returns:
      paused flag
    • setPaused

      void setPaused(boolean paused)
      Modifies the Paused property and notifies the listeners
      Parameters:
      paused -
    • setSelectedEvent

      int setSelectedEvent(int eventNumber)
      Change the selected event on the log panel. Will cause scrollToBottom to be turned off.
      Parameters:
      eventNumber -
      Returns:
      row number or -1 if row with log4jid property with that number was not found
    • addPreferencePropertyChangeListener

      void addPreferencePropertyChangeListener(PropertyChangeListener listener)
      Add a preference propertyChangeListener
      Parameters:
      listener -
    • toggleCyclic

      void toggleCyclic()
      Toggle the LoggingEvent container from either managing a cyclic buffer of events or an ArrayList of events
    • isCyclic

      boolean isCyclic()
      Accessor
      Returns:
      flag answering if LoggingEvent container is a cyclic buffer
    • updateFindRule

      public void updateFindRule(String ruleText)
    • hideSearchResults

      private void hideSearchResults()
    • showSearchResults

      private void showSearchResults()
    • showDetailPane

      private void showDetailPane()
      Display the detail pane, using the last known divider location
    • hideDetailPane

      private void hideDetailPane()
      Hide the detail pane, holding the current divider location for later use
    • showLogTreePanel

      private void showLogTreePanel()
      Display the log tree pane, using the last known divider location
    • hideLogTreePanel

      private void hideLogTreePanel()
      Hide the log tree pane, holding the current divider location for later use
    • createDockwindowToolbar

      private JToolBar createDockwindowToolbar()
      Return a toolbar used by the undocked LogPanel's frame
      Returns:
      toolbar
    • updateStatusBar

      protected void updateStatusBar()
      Update the status bar with current selected row and row count
    • setDetailPaneConversionPattern

      private void setDetailPaneConversionPattern(String conversionPattern)
      Update the detail pane layout text
      Parameters:
      conversionPattern - layout text
    • getDetailPaneConversionPattern

      private String getDetailPaneConversionPattern()
      Accessor
      Returns:
      conversionPattern layout text
    • clearModel

      private void clearModel()
      Reset the LoggingEvent container, detail panel and status bar
    • findNextColorizedEvent

      public void findNextColorizedEvent()
    • findPreviousColorizedEvent

      public void findPreviousColorizedEvent()
    • findNext

      public void findNext()
      Finds the next row matching the current find rule, and ensures it is made visible
    • findPrevious

      public void findPrevious()
      Finds the previous row matching the current find rule, and ensures it is made visible
    • dock

      private void dock()
      Docks this DockablePanel by hiding the JFrame and placing the Panel back inside the LogUI window.
    • loadDefaultColumnSettings

      private void loadDefaultColumnSettings(LoadSettingsEvent event)
      Load default column settings if no settings exist for this identifier
      Parameters:
      event -
    • getMaxColumnWidth

      private int getMaxColumnWidth(int index)
      Iterate over all values in the column and return the longest width
      Parameters:
      index - column index
      Returns:
      longest width - relies on FontMetrics.stringWidth for calculation
    • getToolTipTextForEvent

      private String getToolTipTextForEvent(LoggingEventWrapper loggingEventWrapper)
    • updateOtherModels

      private void updateOtherModels(org.apache.log4j.spi.LoggingEvent event)
      ensures the Entry map of all the unque logger names etc, that is used for the Filter panel is updated with any new information from the event
      Parameters:
      event -
    • findNextMarker

      public void findNextMarker()
    • findPreviousMarker

      public void findPreviousMarker()
    • clearAllMarkers

      public void clearAllMarkers()
    • toggleMarker

      public void toggleMarker()
    • layoutComponents

      public void layoutComponents()
    • setFindText

      public void setFindText(String findText)
    • getFindText

      public String getFindText()