Package org.apache.log4j.chainsaw
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:
-
ColorPanel
ExpressionRule
LoggingEventFieldResolver
- Serialized Form
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
(package private) class
private class
private class
private final class
This 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 class
Thread that periodically checks if the selected row has changed, and if it was, updates the Detail Panel with the detailed Logging informationprivate class
private class
private final class
Update active tooltipprivate final class
private class
(package private) class
(package private) class
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ApplicationPreferenceModel
private org.apache.log4j.rule.Rule
private final JFrame
private final RuleColorizer
private ColorPanel
(package private) static final String
private String
private Point
private int
private JTable
private static final double
private static final double
private final JEditorPane
private final EventDetailLayout
private JScrollPane
private final JPanel
private final LogPanel.DetailPaneUpdater
private JToolBar
private final int
private final Action
private JScrollPane
private final DockablePanel
private LogPanel.AutoFilterComboBox
private final FilterModel
private LogPanel.AutoFilterComboBox
private org.apache.log4j.rule.Rule
private org.apache.log4j.rule.Rule
private final String
private boolean
private double
private static final int
private final org.apache.log4j.Logger
private final JFrame
private final LogPanelPreferencePanel
private final LoggerNameTreePanel
private final JSplitPane
private int
private LogPanel.ToggleToolTips
private TableCellEditor
private final JSplitPane
private boolean
private final LogPanelPreferenceModel
private int
private final TableColorizingRenderer
private EventContainer
private JScrollPane
private TableColorizingRenderer
private boolean
private final RuleMediator
private final JSortTable
private LogPanel.ToggleToolTips
private final ChainsawStatusBar
private final JSortTable
(package private) static final String
(package private) static final String
private final EventContainer
private final RuleMediator
private static final DateFormat
private final JFrame
private final JToolBar
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.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) void
Add an eventCountListener(package private) void
Add a preference propertyChangeListenerprivate void
buildCombo
(LogPanel.AutoFilterComboBox combo, boolean isFiltering, LogPanel.AutoFilterComboBox.AutoFilterComboBoxModel otherModel) private com.thoughtworks.xstream.XStream
static void
centerAndSetVisible
(Window window) void
(package private) void
Remove all eventsprivate void
Reset the LoggingEvent container, detail panel and status barprivate JToolBar
Return a toolbar used by the undocked LogPanel's frameprivate 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 visiblevoid
void
void
Finds the previous row matching the current find rule, and ensures it is made visiblevoid
void
private String
Accessor(package private) List
Return all events(package private) List
Return the events that are visible with the current filter appliedprivate Action
private Action
(package private) String
AccessorAccessor(package private) 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 widthAccessorprivate String
getToolTipTextForEvent
(LoggingEventWrapper loggingEventWrapper) private String
getValueOf
(int row, int column) private void
Hide the detail pane, holding the current divider location for later useprivate void
Hide the log tree pane, holding the current divider location for later useprivate void
(package private) boolean
isCyclic()
Accessor(package private) boolean
Accessor(package private) boolean
Accessor(package private) boolean
isPaused()
Accessorboolean
Accessor(package private) boolean
void
private void
Load default column settings if no settings exist for this identifiervoid
loadSettings
(LoadSettingsEvent event) Load settings from the panel preference modelvoid
receiveEventBatch
(String ident, List<org.apache.log4j.spi.LoggingEvent> events) Process events associated with the identifier.void
saveSettings
(SaveSettingsEvent event) Save preferences to the panel preference modelprivate void
void
private void
setDetailPaneConversionPattern
(String conversionPattern) Update the detail pane layout textvoid
setFindText
(String findText) (package private) void
setPaused
(boolean paused) Modifies the Paused property and notifies the listenersvoid
setRefineFocusText
(String refineFocusText) (package private) int
setSelectedEvent
(int eventNumber) Change the selected event on the log panel.(package private) void
Display the color rule frameprivate void
Display the detail pane, using the last known divider locationprivate void
Display the log tree pane, using the last known divider location(package private) void
Display the panel preferences frameprivate void
(package private) void
Toggle the LoggingEvent container from either managing a cyclic buffer of events or an ArrayList of events(package private) void
Toggle panel preference for detail visibility on or off(package private) void
Toggle panel preference for logger tree visibility on or offvoid
void
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
(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 eventprotected void
Update the status bar with current selected row and row countMethods inherited from class org.apache.log4j.chainsaw.DockablePanel
getPreferredSize, isDocked, setDocked
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
-
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:
getNamespace
in interfaceProfileable
- Returns:
- namespace
- See Also:
-
getInterestedIdentifier
Accessor- Specified by:
getInterestedIdentifier
in 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:
receiveEventBatch
in interfaceEventBatchListener
- Parameters:
ident
- identifier shared by eventsevents
- list of LoggingEvent objects
-
loadSettings
Load settings from the panel preference model- Specified by:
loadSettings
in interfaceSettingsListener
- Parameters:
event
-- See Also:
-
saveSettings
Save preferences to the panel preference model- Specified by:
saveSettings
in 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
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
-
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
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
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
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
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
-