sdeboy 2004/12/28 00:14:35
Modified: src/java/org/apache/log4j/chainsaw LogUI.java
Log:
Setting 'hostname' and 'application' keys for Chainsaw's logger repository to
chainsaw & log. When using the default tab identifier, this will result in
chainsaw's internal logging events to route to a tab called 'chainsaw-log'.
With this change, you can once again use PROP.hostname as a tab identifier in
Chainsaw to route events from a single host to a single tab, regardless of the
number of socketappender connections from that host.
Revision Changes Path
1.115 +73 -77
logging-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java
Index: LogUI.java
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -r1.114 -r1.115
--- LogUI.java 7 Dec 2004 18:35:05 -0000 1.114
+++ LogUI.java 28 Dec 2004 08:14:34 -0000 1.115
@@ -294,12 +294,7 @@
}
logUI.cyclicBufferSize = model.getCyclicBufferSize();
- PropertyFilter propFilter = new PropertyFilter();
-
propFilter.setProperties(Constants.HOSTNAME_KEY+"=chainsaw,"+Constants.APPLICATION_KEY+"=log");
-
logUI.handler = new ChainsawAppenderHandler();
- logUI.handler.addFilter(propFilter);
-
logUI.handler.addEventBatchListener(logUI.new
NewTabEventBatchReceiver());
/**
* TODO until we work out how JoranConfigurator might be able to have
@@ -311,6 +306,8 @@
//configuration initialized here
logUI.ensureChainsawAppenderHandlerAdded();
logger = LogManager.getLogger(LogUI.class);
+
logger.getLoggerRepository().setProperty(Constants.APPLICATION_KEY,"log");
+
logger.getLoggerRepository().setProperty(Constants.HOSTNAME_KEY,"chainsaw");
String config = model.getConfigurationURL();
if(config!=null && (!(config.trim().equals("")))) {
@@ -366,18 +363,16 @@
applyLookAndFeel(model.getLookAndFeelClassName());
handler = new ChainsawAppenderHandler(appender);
- PropertyFilter propFilter = new PropertyFilter();
-
propFilter.setProperties(Constants.HOSTNAME_KEY+"=chainsaw,"+Constants.APPLICATION_KEY+"=log");
- handler.addFilter(propFilter);
handler.addEventBatchListener(new NewTabEventBatchReceiver());
-
- LogManager.getRootLogger().addAppender(appender);
+
+ logger = LogManager.getLogger(LogUI.class);
setShutdownAction(
- new AbstractAction() {
- public void actionPerformed(ActionEvent e) {
- }
- });
+ new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ }
+ });
+
activateViewer();
getApplicationPreferenceModel().apply(model);
@@ -1732,82 +1727,83 @@
}
private void buildLogPanel(
- boolean customExpression, final String ident, final List events)
- throws IllegalArgumentException {
- final LogPanel thisPanel = new LogPanel(getStatusBar(), ident,
cyclicBufferSize);
+ boolean customExpression, final String ident, final List events)
+ throws IllegalArgumentException {
+ final LogPanel thisPanel = new LogPanel(getStatusBar(), ident,
cyclicBufferSize);
- /**
- * Now add the panel as a batch listener so it can handle it's
own
- * batchs
- */
- if (customExpression) {
- handler.addCustomEventBatchListener(ident, thisPanel);
- } else {
- identifierPanels.add(thisPanel);
- handler.addEventBatchListener(thisPanel);
- }
+ /**
+ * Now add the panel as a batch listener so it can handle it's
own
+ * batchs
+ */
+ if (customExpression) {
+ handler.addCustomEventBatchListener(ident, thisPanel);
+ } else {
+ identifierPanels.add(thisPanel);
+ handler.addEventBatchListener(thisPanel);
+ }
- TabIconHandler iconHandler = new TabIconHandler(ident);
- thisPanel.addEventCountListener(iconHandler);
-
+ TabIconHandler iconHandler = new TabIconHandler(ident);
+ thisPanel.addEventCountListener(iconHandler);
+
- tabbedPane.addChangeListener(iconHandler);
+ tabbedPane.addChangeListener(iconHandler);
- PropertyChangeListener toolbarMenuUpdateListener =
- new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- tbms.stateChange();
- }
- };
+ PropertyChangeListener toolbarMenuUpdateListener =
+ new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ tbms.stateChange();
+ }
+ };
+
+ thisPanel.addPropertyChangeListener(toolbarMenuUpdateListener);
+
thisPanel.addPreferencePropertyChangeListener(toolbarMenuUpdateListener);
+
+ thisPanel.addPropertyChangeListener(
+ "docked",
+ new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ LogPanel logPanel = (LogPanel) evt.getSource();
+
+ if (logPanel.isDocked()) {
+ getPanelMap().put(logPanel.getIdentifier(), logPanel);
+ getTabbedPane().addANewTab(
+ logPanel.getIdentifier(), logPanel, null);
+
getTabbedPane().setSelectedTab(getTabbedPane().indexOfTab(logPanel.getIdentifier()));
+ } else {
+ getTabbedPane().remove(logPanel);
+ }
+ }
+ });
- thisPanel.addPropertyChangeListener(toolbarMenuUpdateListener);
- thisPanel.addPreferencePropertyChangeListener(toolbarMenuUpdateListener);
+ logger.debug("adding logpanel to tabbed pane: " + ident);
+
+ //NOTE: tab addition is a very fragile process - if you modify this
code,
+ //verify the frames in the individual log panels initialize to their
+ //correct sizes
+ getTabbedPane().add(ident, thisPanel);
+ getPanelMap().put(ident, thisPanel);
- thisPanel.addPropertyChangeListener(
- "docked",
- new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- LogPanel logPanel = (LogPanel) evt.getSource();
+ getSettingsManager().addSettingsListener(thisPanel);
+ getSettingsManager().configure(thisPanel);
- if (logPanel.isDocked()) {
- getPanelMap().put(logPanel.getIdentifier(), logPanel);
+ /**
+ * Let the new LogPanel receive this batch
+ */
+ thisPanel.receiveEventBatch(ident, events);
+
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ public void run() {
getTabbedPane().addANewTab(
- logPanel.getIdentifier(), logPanel, null);
-
getTabbedPane().setSelectedTab(getTabbedPane().indexOfTab(logPanel.getIdentifier()));
- } else {
- getTabbedPane().remove(logPanel);
+ ident, thisPanel, new
ImageIcon(ChainsawIcons.ANIM_RADIO_TOWER));
}
- }
- });
+ });
- logger.debug("adding logpanel to tabbed pane: " + ident);
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
+ String msg = "added tab " + ident;
+ MessageCenter.getInstance().getLogger().debug(msg);
}
- });
- getTabbedPane().add(ident, thisPanel);
- getPanelMap().put(ident, thisPanel);
-
- getSettingsManager().addSettingsListener(thisPanel);
- getSettingsManager().configure(thisPanel);
-
- /**
- * Let the new LogPanel receive this batch
- */
- thisPanel.receiveEventBatch(ident, events);
-
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- getTabbedPane().addANewTab(
- ident, thisPanel, new ImageIcon(ChainsawIcons.ANIM_RADIO_TOWER));
- }
- });
- String msg = "added tab " + ident;
- MessageCenter.getInstance().getLogger().debug(msg);
- }
public void createCustomExpressionLogPanel(String ident) {
//collect events matching the rule from all of the tabs
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]