Class LogPanel

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.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:
    ColorPanel, ExpressionRule, LoggingEventFieldResolver, Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void addEventCountListener​(EventCountListener l)
      Add an eventCountListener
      (package private) void addPreferencePropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Add a preference propertyChangeListener
      private void buildCombo​(LogPanel.AutoFilterComboBox combo, boolean isFiltering, LogPanel.AutoFilterComboBox.AutoFilterComboBoxModel otherModel)  
      private com.thoughtworks.xstream.XStream buildXStreamForLogPanelPreference()  
      static void centerAndSetVisible​(java.awt.Window window)  
      void clearAllMarkers()  
      (package private) void clearEvents()
      Remove all events
      private void clearModel()
      Reset the LoggingEvent container, detail panel and status bar
      private javax.swing.JToolBar createDockwindowToolbar()
      Return a toolbar used by the undocked LogPanel's frame
      private void dock()
      Docks this DockablePanel by hiding the JFrame and placing the Panel back inside the LogUI window.
      void findNext()
      Finds the next row matching the current find rule, and ensures it is made visible
      void findNextColorizedEvent()  
      void findNextMarker()  
      void findPrevious()
      Finds the previous row matching the current find rule, and ensures it is made visible
      void findPreviousColorizedEvent()  
      void findPreviousMarker()  
      private java.lang.String getDetailPaneConversionPattern()
      Accessor
      (package private) java.util.List getEvents()
      Return all events
      (package private) java.util.List getFilteredEvents()
      Return the events that are visible with the current filter applied
      private javax.swing.Action getFindNextAction()  
      private javax.swing.Action getFindPreviousAction()  
      java.lang.String getFindText()  
      (package private) java.lang.String getIdentifier()
      Accessor
      java.lang.String getInterestedIdentifier()
      Accessor
      (package private) java.util.List<LoggingEventWrapper> getMatchingEvents​(org.apache.log4j.rule.Rule rule)  
      private int getMaxColumnWidth​(int index)
      Iterate over all values in the column and return the longest width
      java.lang.String getNamespace()
      Accessor
      java.lang.String getRefineFocusText()  
      private java.lang.String getToolTipTextForEvent​(LoggingEventWrapper loggingEventWrapper)  
      private java.lang.String getValueOf​(int row, int column)  
      private void hideDetailPane()
      Hide the detail pane, holding the current divider location for later use
      private void hideLogTreePanel()
      Hide the log tree pane, holding the current divider location for later use
      private void hideSearchResults()  
      (package private) boolean isCyclic()
      Accessor
      (package private) boolean isDetailVisible()
      Accessor
      (package private) boolean isLogTreeVisible()
      Accessor
      (package private) boolean isPaused()
      Accessor
      boolean isScrollToBottom()
      Accessor
      (package private) boolean isSearchResultsVisible()  
      void layoutComponents()  
      private void loadDefaultColumnSettings​(LoadSettingsEvent event)
      Load default column settings if no settings exist for this identifier
      void loadSettings​(LoadSettingsEvent event)
      Load settings from the panel preference model
      void receiveEventBatch​(java.lang.String ident, java.util.List<org.apache.log4j.spi.LoggingEvent> events)
      Process events associated with the identifier.
      void saveSettings​(SaveSettingsEvent event)
      Save preferences to the panel preference model
      private void scrollToBottom()  
      void scrollToTop()  
      private void setDetailPaneConversionPattern​(java.lang.String conversionPattern)
      Update the detail pane layout text
      void setFindText​(java.lang.String findText)  
      (package private) void setPaused​(boolean paused)
      Modifies the Paused property and notifies the listeners
      void setRefineFocusText​(java.lang.String refineFocusText)  
      (package private) int setSelectedEvent​(int eventNumber)
      Change the selected event on the log panel.
      (package private) void showColorPreferences()
      Display the color rule frame
      private void showDetailPane()
      Display the detail pane, using the last known divider location
      private void showLogTreePanel()
      Display the log tree pane, using the last known divider location
      (package private) void showPreferences()
      Display the panel preferences frame
      private void showSearchResults()  
      (package private) void toggleCyclic()
      Toggle the LoggingEvent container from either managing a cyclic buffer of events or an ArrayList of events
      (package private) void toggleDetailVisible()
      Toggle panel preference for detail visibility on or off
      (package private) void toggleLogTreeVisible()
      Toggle panel preference for logger tree visibility on or off
      void toggleMarker()  
      void toggleScrollToBottom()
      Mutator
      (package private) void undock()
      Undocks this DockablePanel by removing the panel from the LogUI window and placing it inside it's own JFrame.
      void updateFindRule​(java.lang.String ruleText)  
      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
      protected void updateStatusBar()
      Update the status bar with current selected row and row count
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • TIMESTAMP_DATE_FORMAT

        private static final java.text.DateFormat TIMESTAMP_DATE_FORMAT
      • DEFAULT_DETAIL_SPLIT_LOCATION

        private static final double DEFAULT_DETAIL_SPLIT_LOCATION
        See Also:
        Constant Field Values
      • DEFAULT_LOG_TREE_SPLIT_LOCATION

        private static final double DEFAULT_LOG_TREE_SPLIT_LOCATION
        See Also:
        Constant Field Values
      • identifier

        private final java.lang.String identifier
      • logPanelPreferencesFrame

        private final javax.swing.JFrame logPanelPreferencesFrame
      • colorFrame

        private final javax.swing.JFrame colorFrame
      • undockedFrame

        private final javax.swing.JFrame undockedFrame
      • dockingAction

        private final javax.swing.Action dockingAction
      • undockedToolbar

        private final javax.swing.JToolBar undockedToolbar
      • detail

        private final javax.swing.JEditorPane detail
      • lowerPanel

        private final javax.swing.JSplitPane lowerPanel
      • detailPanel

        private final javax.swing.JPanel detailPanel
      • nameTreeAndMainPanelSplit

        private final javax.swing.JSplitPane nameTreeAndMainPanelSplit
      • tableRuleMediator

        private final RuleMediator tableRuleMediator
      • searchRuleMediator

        private final RuleMediator searchRuleMediator
      • lastLogTreePanelSplitLocation

        private double lastLogTreePanelSplitLocation
      • currentPoint

        private java.awt.Point currentPoint
      • currentTable

        private javax.swing.JTable currentTable
      • paused

        private boolean paused
      • findRule

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

        private java.lang.String currentFindRuleText
      • findMarkerRule

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

        private final int dividerSize
      • LOG_PANEL_SERIALIZATION_VERSION_NUMBER

        private static final int LOG_PANEL_SERIALIZATION_VERSION_NUMBER
        See Also:
        Constant Field Values
      • previousLastIndex

        private int previousLastIndex
      • logger

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

        private javax.swing.JScrollPane eventsPane
      • currentSearchMatchCount

        private int currentSearchMatchCount
      • clearTableExpressionRule

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

        private int lowerPanelDividerLocation
      • searchTable

        private final JSortTable searchTable
      • detailPane

        private javax.swing.JScrollPane detailPane
      • searchPane

        private javax.swing.JScrollPane searchPane
      • markerCellEditor

        private javax.swing.table.TableCellEditor markerCellEditor
      • detailToolbar

        private javax.swing.JToolBar detailToolbar
      • searchResultsDisplayed

        private boolean searchResultsDisplayed
      • isDetailPanelVisible

        private boolean isDetailPanelVisible
    • Constructor Detail

      • LogPanel

        public LogPanel​(ChainsawStatusBar statusBar,
                        java.lang.String identifier,
                        int cyclicBufferSize,
                        java.util.Map<java.lang.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 Detail

      • getValueOf

        private java.lang.String getValueOf​(int row,
                                            int column)
      • getFindNextAction

        private javax.swing.Action getFindNextAction()
      • getFindPreviousAction

        private javax.swing.Action getFindPreviousAction()
      • isScrollToBottom

        public boolean isScrollToBottom()
        Accessor
        Returns:
        scrollToBottom
      • setRefineFocusText

        public void setRefineFocusText​(java.lang.String refineFocusText)
      • getRefineFocusText

        public java.lang.String getRefineFocusText()
      • toggleScrollToBottom

        public void toggleScrollToBottom()
        Mutator
      • scrollToBottom

        private void scrollToBottom()
      • scrollToTop

        public void scrollToTop()
      • receiveEventBatch

        public void receiveEventBatch​(java.lang.String ident,
                                      java.util.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
      • buildXStreamForLogPanelPreference

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

        void showPreferences()
        Display the panel preferences frame
      • centerAndSetVisible

        public static void centerAndSetVisible​(java.awt.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

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

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

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

        void clearEvents()
        Remove all events
      • getIdentifier

        java.lang.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​(java.beans.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​(java.lang.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 javax.swing.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​(java.lang.String conversionPattern)
        Update the detail pane layout text
        Parameters:
        conversionPattern - layout text
      • getDetailPaneConversionPattern

        private java.lang.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 java.lang.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​(java.lang.String findText)
      • getFindText

        public java.lang.String getFindText()