Class LogPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.apache.log4j.chainsaw.DockablePanel
org.apache.log4j.chainsaw.LogPanel
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, EventBatchListener, Profileable, SettingsListener
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:
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
- 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class(package private) classprivate classprivate classprivate final classThis class receives notification when the Refine focus or find field is updated, where a background thread periodically wakes up and checks if they have stopped typing yet.private classThread that periodically checks if the selected row has changed, and if it was, updates the Detail Panel with the detailed Logging informationprivate classprivate classprivate final classUpdate active tooltipprivate final classprivate class(package private) class(package private) classNested classes/interfaces inherited from class JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ApplicationPreferenceModelprivate org.apache.log4j.rule.Ruleprivate final JFrameprivate final RuleColorizerprivate ColorPanel(package private) static final Stringprivate Stringprivate Pointprivate intprivate JTableprivate static final doubleprivate static final doubleprivate final JEditorPaneprivate final EventDetailLayoutprivate JScrollPaneprivate final JPanelprivate final LogPanel.DetailPaneUpdaterprivate JToolBarprivate final intprivate final Actionprivate JScrollPaneprivate final DockablePanelprivate LogPanel.AutoFilterComboBoxprivate final FilterModelprivate LogPanel.AutoFilterComboBoxprivate org.apache.log4j.rule.Ruleprivate org.apache.log4j.rule.Ruleprivate final Stringprivate booleanprivate doubleprivate static final intprivate final org.apache.log4j.Loggerprivate final JFrameprivate final LogPanelPreferencePanelprivate final LoggerNameTreePanelprivate final JSplitPaneprivate intprivate LogPanel.ToggleToolTipsprivate TableCellEditorprivate final JSplitPaneprivate booleanprivate final LogPanelPreferenceModelprivate intprivate final TableColorizingRendererprivate EventContainerprivate JScrollPaneprivate TableColorizingRendererprivate booleanprivate final RuleMediatorprivate final JSortTableprivate LogPanel.ToggleToolTipsprivate final ChainsawStatusBarprivate final JSortTable(package private) static final String(package private) static final Stringprivate final EventContainerprivate final RuleMediatorprivate static final DateFormatprivate final JFrameprivate final JToolBarFields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionLogPanel(ChainsawStatusBar statusBar, String identifier, int cyclicBufferSize, Map<String, RuleColorizer> allColorizers, ApplicationPreferenceModel applicationPreferenceModel) Creates a new LogPanel object. -
Method Summary
Modifier and TypeMethodDescription(package private) voidAdd an eventCountListener(package private) voidAdd a preference propertyChangeListenerprivate voidbuildCombo(LogPanel.AutoFilterComboBox combo, boolean isFiltering, LogPanel.AutoFilterComboBox.AutoFilterComboBoxModel otherModel) private com.thoughtworks.xstream.XStreamstatic voidcenterAndSetVisible(Window window) void(package private) voidRemove all eventsprivate voidReset the LoggingEvent container, detail panel and status barprivate JToolBarReturn a toolbar used by the undocked LogPanel's frameprivate voiddock()Docks this DockablePanel by hiding the JFrame and placing the Panel back inside the LogUI window.voidfindNext()Finds the next row matching the current find rule, and ensures it is made visiblevoidvoidvoidFinds the previous row matching the current find rule, and ensures it is made visiblevoidvoidprivate StringAccessor(package private) ListReturn all events(package private) ListReturn the events that are visible with the current filter appliedprivate Actionprivate Action(package private) StringAccessorAccessor(package private) List<LoggingEventWrapper> getMatchingEvents(org.apache.log4j.rule.Rule rule) private intgetMaxColumnWidth(int index) Iterate over all values in the column and return the longest widthAccessorprivate StringgetToolTipTextForEvent(LoggingEventWrapper loggingEventWrapper) private StringgetValueOf(int row, int column) private voidHide the detail pane, holding the current divider location for later useprivate voidHide the log tree pane, holding the current divider location for later useprivate void(package private) booleanisCyclic()Accessor(package private) booleanAccessor(package private) booleanAccessor(package private) booleanisPaused()AccessorbooleanAccessor(package private) booleanvoidprivate voidLoad default column settings if no settings exist for this identifiervoidloadSettings(LoadSettingsEvent event) Load settings from the panel preference modelvoidreceiveEventBatch(String ident, List<org.apache.log4j.spi.LoggingEvent> events) Process events associated with the identifier.voidsaveSettings(SaveSettingsEvent event) Save preferences to the panel preference modelprivate voidvoidprivate voidsetDetailPaneConversionPattern(String conversionPattern) Update the detail pane layout textvoidsetFindText(String findText) (package private) voidsetPaused(boolean paused) Modifies the Paused property and notifies the listenersvoidsetRefineFocusText(String refineFocusText) (package private) intsetSelectedEvent(int eventNumber) Change the selected event on the log panel.(package private) voidDisplay the color rule frameprivate voidDisplay the detail pane, using the last known divider locationprivate voidDisplay the log tree pane, using the last known divider location(package private) voidDisplay the panel preferences frameprivate void(package private) voidToggle the LoggingEvent container from either managing a cyclic buffer of events or an ArrayList of events(package private) voidToggle panel preference for detail visibility on or off(package private) voidToggle panel preference for logger tree visibility on or offvoidvoidMutator(package private) voidundock()Undocks this DockablePanel by removing the panel from the LogUI window and placing it inside it's own JFrame.voidupdateFindRule(String ruleText) private voidupdateOtherModels(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 eventprotected voidUpdate the status bar with current selected row and row countMethods inherited from class DockablePanel
getPreferredSize, isDocked, setDockedMethods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class 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, updateMethods inherited from class 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, validateTreeMethods inherited from class 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
-
Field Details
-
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
-
statusBar
-
logPanelPreferencesFrame
-
colorPanel
-
colorFrame
-
undockedFrame
-
externalPanel
-
dockingAction
-
undockedToolbar
-
table
-
renderer
-
tableModel
-
detail
-
lowerPanel
-
detailPaneUpdater
-
detailPanel
-
nameTreeAndMainPanelSplit
-
logTreePanel
-
preferenceModel
-
applicationPreferenceModel
-
logPanelPreferencesPanel
-
filterModel
-
colorizer
-
tableRuleMediator
-
searchRuleMediator
-
detailLayout
-
lastLogTreePanelSplitLocation
private double lastLogTreePanelSplitLocation -
currentPoint
-
currentTable
-
paused
private boolean paused -
findRule
private org.apache.log4j.rule.Rule findRule -
currentFindRuleText
-
findMarkerRule
private org.apache.log4j.rule.Rule findMarkerRule -
dividerSize
private final int dividerSize -
TABLE_COLUMN_ORDER
- See Also:
-
TABLE_COLUMN_WIDTHS
- See Also:
-
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
-
findCombo
-
eventsPane
-
currentSearchMatchCount
private int currentSearchMatchCount -
clearTableExpressionRule
private org.apache.log4j.rule.Rule clearTableExpressionRule -
lowerPanelDividerLocation
private int lowerPanelDividerLocation -
searchModel
-
searchTable
-
searchRenderer
-
mainToggleToolTips
-
searchToggleToolTips
-
detailPane
-
searchPane
-
markerCellEditor
-
detailToolbar
-
searchResultsDisplayed
private boolean searchResultsDisplayed -
colorizedEventAndSearchMatchThumbnail
-
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 applicationidentifier- used to load and save settings
-
-
Method Details
-
getValueOf
-
getFindNextAction
-
getFindPreviousAction
-
buildCombo
private void buildCombo(LogPanel.AutoFilterComboBox combo, boolean isFiltering, LogPanel.AutoFilterComboBox.AutoFilterComboBoxModel otherModel) -
isScrollToBottom
public boolean isScrollToBottom()Accessor- Returns:
- scrollToBottom
-
setRefineFocusText
-
getRefineFocusText
-
toggleScrollToBottom
public void toggleScrollToBottom()Mutator -
scrollToBottom
private void scrollToBottom() -
scrollToTop
public void scrollToTop() -
getNamespace
Accessor- Specified by:
getNamespacein interfaceProfileable- Returns:
- namespace
- See Also:
-
getInterestedIdentifier
Accessor- Specified by:
getInterestedIdentifierin interfaceEventBatchListener- Returns:
- identifier
- See Also:
-
receiveEventBatch
Process events associated with the identifier. Currently assumes it only receives events which share this LogPanel's identifier- Specified by:
receiveEventBatchin interfaceEventBatchListener- Parameters:
ident- identifier shared by eventsevents- list of LoggingEvent objects
-
loadSettings
Load settings from the panel preference model- Specified by:
loadSettingsin interfaceSettingsListener- Parameters:
event-- See Also:
-
saveSettings
Save preferences to the panel preference model- Specified by:
saveSettingsin interfaceSettingsListener- Parameters:
event-- See Also:
-
buildXStreamForLogPanelPreference
private com.thoughtworks.xstream.XStream buildXStreamForLogPanelPreference() -
showPreferences
void showPreferences()Display the panel preferences frame -
centerAndSetVisible
-
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
-
getFilteredEvents
List getFilteredEvents()Return the events that are visible with the current filter applied- Returns:
- list of LoggingEvents
-
getMatchingEvents
-
clearEvents
void clearEvents()Remove all events -
getIdentifier
-
undock
void undock()Undocks this DockablePanel by removing the panel from the LogUI window and placing it inside it's own JFrame. -
addEventCountListener
-
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
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
-
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
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
Update the detail pane layout text- Parameters:
conversionPattern- layout text
-
getDetailPaneConversionPattern
-
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
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
-
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
-
getFindText
-