You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gr...@apache.org on 2023/09/30 19:15:45 UTC

[logging-chainsaw] branch master updated (9c91e98 -> 30aa16e)

This is an automated email from the ASF dual-hosted git repository.

grobmeier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git


    from 9c91e98  added final and generics, improved variable names
     new cf0783b  improved logging, removed printStacktrace
     new 2759662  removed: commented code for configurationURL (at startup)
     new 614cb0f  improved use of logger
     new 909ae41  made use of imports instead of fqcn
     new 30aa16e  cleanups: java doc, removed tiny portions of commented code, constants

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/apache/log4j/chainsaw/LogUI.java | 108 ++++++---------------
 1 file changed, 27 insertions(+), 81 deletions(-)


[logging-chainsaw] 02/05: removed: commented code for configurationURL (at startup)

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

grobmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git

commit 275966292e8393e9c579214d7c311b054891058f
Author: Christian Grobmeier <cg...@grobmeier.de>
AuthorDate: Sat Sep 30 21:02:35 2023 +0200

    removed: commented code for configurationURL (at startup)
---
 src/main/java/org/apache/log4j/chainsaw/LogUI.java | 41 ----------------------
 1 file changed, 41 deletions(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
index db6489a..a35cea8 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
@@ -295,47 +295,6 @@ public class LogUI extends JFrame {
             logger.error("Uncaught exception in thread {}", t.getName(), e);
         });
 
-//        String config = configurationURLAppArg;
-//        if (config != null) {
-//            logger.info("Command-line configuration arg provided (overriding auto-configuration URL) - using: " + config);
-//        } else {
-//            config = model.getConfigurationURL();
-//        }
-
-//        if (config != null && (!config.trim().equals(""))) {
-//            config = config.trim();
-//            try {
-//                URL configURL = new URL(config);
-//                logger.info("Using '" + config + "' for auto-configuration");
-////                logUI.loadConfigurationUsingPluginClassLoader(configURL);
-//            } catch (MalformedURLException e) {
-//                logger.error("Initial configuration - failed to convert config string to url", e);
-//            } catch (IOException e) {
-//                logger.error("Unable to access auto-configuration URL: " + config);
-//            }
-//        }
-
-        //register a listener to load the configuration when it changes (avoid having to restart Chainsaw when applying a new configuration)
-        //this doesn't remove receivers from receivers panel, it just triggers DOMConfigurator.configure.
-//        model.addPropertyChangeListener("configurationURL", evt -> {
-//            String newConfiguration = evt.getNewValue().toString();
-//            if (newConfiguration != null && !(newConfiguration.trim().equals(""))) {
-//                newConfiguration = newConfiguration.trim();
-//                try {
-//                    logger.info("loading updated configuration: " + newConfiguration);
-//                    URL newConfigurationURL = new URL(newConfiguration);
-//                    File file = new File(newConfigurationURL.toURI());
-//                    if (file.exists()) {
-////                        logUI.loadConfigurationUsingPluginClassLoader(newConfigurationURL);
-//                    } else {
-//                        logger.info("Updated configuration but file does not exist");
-//                    }
-//                } catch (MalformedURLException | URISyntaxException e) {
-//                    logger.error("Updated configuration - failed to convert config string to URL", e);
-//                }
-//            }
-//        });
-
         EventQueue.invokeLater(logUI::activateViewer);
         EventQueue.invokeLater(logUI::buildChainsawLogPanel);
 


[logging-chainsaw] 04/05: made use of imports instead of fqcn

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

grobmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git

commit 909ae41563c7922e0cacfa9f34b5ce0d843ccd56
Author: Christian Grobmeier <cg...@grobmeier.de>
AuthorDate: Sat Sep 30 21:05:29 2023 +0200

    made use of imports instead of fqcn
---
 src/main/java/org/apache/log4j/chainsaw/LogUI.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
index 22d4768..abe39b2 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
@@ -34,6 +34,8 @@ import org.apache.log4j.rule.ExpressionRule;
 import org.apache.log4j.rule.Rule;
 import org.apache.log4j.spi.Decoder;
 import org.apache.log4j.xml.XMLDecoder;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -128,7 +130,7 @@ public class LogUI extends JFrame {
     private List<ReceiverEventListener> m_receiverListeners = new ArrayList<>();
     private ZeroConfPlugin m_zeroConf = new ZeroConfPlugin();
 
-    private static org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger();
+    private static Logger logger = LogManager.getLogger();
 
     private final Object initializationLock = new Object();
 


[logging-chainsaw] 03/05: improved use of logger

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

grobmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git

commit 614cb0ff46ddab885d339def484b99266d6a8bc8
Author: Christian Grobmeier <cg...@grobmeier.de>
AuthorDate: Sat Sep 30 21:04:33 2023 +0200

    improved use of logger
---
 src/main/java/org/apache/log4j/chainsaw/LogUI.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
index a35cea8..22d4768 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
@@ -338,7 +338,7 @@ public class LogUI extends JFrame {
             final List fileList = (List) evt.getNewValue();
 
             Thread thread = new Thread(() -> {
-                logger.debug("Loading files: " + fileList);
+                logger.debug("Loading files: {}", fileList);
                 for (Object aFileList : fileList) {
                     File file = (File) aFileList;
                     final Decoder decoder = new XMLDecoder();
@@ -770,7 +770,7 @@ public class LogUI extends JFrame {
             container.add(new JScrollPane(tutorialArea), BorderLayout.CENTER);
         } catch (Exception e) {
             logger.error("Can't load tutorial", e);
-            statusBar.setMessage("Can't load tutorail");
+            statusBar.setMessage("Can't load tutorial");
         }
 
         tutorialFrame.setIconImage(new ImageIcon(ChainsawIcons.HELP).getImage());
@@ -1409,8 +1409,7 @@ public class LogUI extends JFrame {
      * @param visible
      */
     private void setStatusBarVisible(final boolean visible) {
-        logger.debug(
-            "Setting StatusBar to " + visible);
+        logger.debug("Setting StatusBar to {}", visible);
         SwingUtilities.invokeLater(
             () -> statusBar.setVisible(visible));
     }
@@ -1629,7 +1628,7 @@ public class LogUI extends JFrame {
                 }
             });
 
-        logger.debug("adding logpanel to tabbed pane: " + ident);
+        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
@@ -1656,8 +1655,7 @@ public class LogUI extends JFrame {
                         false);
             });
 
-        String msg = "added tab " + ident;
-        logger.debug(msg);
+        logger.debug("added tab {}", ident);
     }
 
     public void createCustomExpressionLogPanel(String ident) {


[logging-chainsaw] 01/05: improved logging, removed printStacktrace

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

grobmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git

commit cf0783bacbf4af05f0c371384512120f43a959f0
Author: Christian Grobmeier <cg...@grobmeier.de>
AuthorDate: Sat Sep 30 21:01:31 2023 +0200

    improved logging, removed printStacktrace
---
 src/main/java/org/apache/log4j/chainsaw/LogUI.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
index 4693e65..db6489a 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
@@ -292,8 +292,7 @@ public class LogUI extends JFrame {
         //configuration initialized here
 
         Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
-            e.printStackTrace();
-            logger.error("Uncaught exception in thread " + t, e);
+            logger.error("Uncaught exception in thread {}", t.getName(), e);
         });
 
 //        String config = configurationURLAppArg;


[logging-chainsaw] 05/05: cleanups: java doc, removed tiny portions of commented code, constants

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

grobmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git

commit 30aa16e6fc954a57d90f57fcaec014432e5424e1
Author: Christian Grobmeier <cg...@grobmeier.de>
AuthorDate: Sat Sep 30 21:15:39 2023 +0200

    cleanups: java doc, removed tiny portions of commented code, constants
---
 src/main/java/org/apache/log4j/chainsaw/LogUI.java | 48 ++++++++--------------
 1 file changed, 18 insertions(+), 30 deletions(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
index abe39b2..baac581 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
@@ -102,6 +102,7 @@ public class LogUI extends JFrame {
     private static final String MAIN_WINDOW_WIDTH = "main.window.width";
     private static final String MAIN_WINDOW_Y = "main.window.y";
     private static final String MAIN_WINDOW_X = "main.window.x";
+    public static final String LABEL_TUTORIAL_STARTED = "TutorialStarted";
     private static ChainsawSplash splash;
     private static final double DEFAULT_MAIN_RECEIVER_SPLIT_LOCATION = 0.85d;
     private final JFrame preferencesFrame = new JFrame();
@@ -248,15 +249,12 @@ public class LogUI extends JFrame {
      * the splash screen, and using the passed shutdown action when the user
      * requests to exit the application (if null, then Chainsaw will exit the vm)
      *
-     * @param model
      * @param newShutdownAction DOCUMENT ME!
      */
     public static void createChainsawGUI(Action newShutdownAction) {
         AbstractConfiguration config = SettingsManager.getInstance().getGlobalConfiguration();
 
-
         if (config.getBoolean("okToRemoveSecurityManager", false)) {
-//            statusBar.setMessage("User has authorised removal of Java Security Manager via preferences");
             System.setSecurityManager(null);
             // this SHOULD set the Policy/Permission stuff for any
             // code loaded from our custom classloader.  
@@ -300,7 +298,7 @@ public class LogUI extends JFrame {
         EventQueue.invokeLater(logUI::activateViewer);
         EventQueue.invokeLater(logUI::buildChainsawLogPanel);
 
-        logger.info("SecurityManager is now: " + System.getSecurityManager());
+        logger.info("SecurityManager is now: {}", System.getSecurityManager());
 
         if (newShutdownAction != null) {
             logUI.setShutdownAction(newShutdownAction);
@@ -329,8 +327,6 @@ public class LogUI extends JFrame {
         setJMenuBar(getToolBarAndMenus().getMenubar());
 
         setTabbedPane(new ChainsawTabbedPane());
-//        getSettingsManager().addSettingsListener(getTabbedPane());
-//        getSettingsManager().configure(getTabbedPane());
 
         /**
          * This adds Drag & Drop capability to Chainsaw
@@ -346,8 +342,6 @@ public class LogUI extends JFrame {
                     final Decoder decoder = new XMLDecoder();
                     try {
                         getStatusBar().setMessage("Loading " + file.getAbsolutePath() + "...");
-//                        FileLoadAction.importURL(handler, decoder, file
-//                            .getName(), file.toURI().toURL());
                     } catch (Exception e) {
                         String errorMsg = "Failed to import a file";
                         logger.error(errorMsg, e);
@@ -423,7 +417,7 @@ public class LogUI extends JFrame {
 
         tb.add(Box.createHorizontalGlue());
 
-        /**
+        /*
          * Setup a listener on the HelpURL property and automatically change the WelcomePages URL
          * to it.
          */
@@ -450,8 +444,6 @@ public class LogUI extends JFrame {
     /**
      * Given the load event, configures the size/location of the main window etc
      * etc.
-     *
-     * @param event DOCUMENT ME!
      */
     private void loadSettings() {
         AbstractConfiguration config = SettingsManager.getInstance().getGlobalConfiguration();
@@ -487,7 +479,7 @@ public class LogUI extends JFrame {
         initGUI();
         loadSettings();
 
-        if (m_receivers.size() == 0) {
+        if (m_receivers.isEmpty()) {
             noReceiversDefined = true;
         }
 
@@ -668,8 +660,7 @@ public class LogUI extends JFrame {
                         String name = getTabbedPane().getTitleAt(index);
 
                         if (
-                            getPanelMap().keySet().contains(name)
-                                && !name.equals(currentName)) {
+                            getPanelMap().containsKey(name) && !name.equals(currentName)) {
                             displayPanel(name, false);
                             tbms.stateChange();
                         } else {
@@ -799,9 +790,9 @@ public class LogUI extends JFrame {
                             gen.start();
                         }
 
-                        putValue("TutorialStarted", Boolean.TRUE);
+                        putValue(LABEL_TUTORIAL_STARTED, Boolean.TRUE);
                     } else {
-                        putValue("TutorialStarted", Boolean.FALSE);
+                        putValue(LABEL_TUTORIAL_STARTED, Boolean.FALSE);
                     }
                 }
             };
@@ -824,7 +815,7 @@ public class LogUI extends JFrame {
                                 }
                             }).start();
                         setEnabled(false);
-                        startTutorial.putValue("TutorialStarted", Boolean.FALSE);
+                        startTutorial.putValue(LABEL_TUTORIAL_STARTED, Boolean.FALSE);
                     }
                 }
             };
@@ -841,7 +832,7 @@ public class LogUI extends JFrame {
         PropertyChangeListener pcl =
             evt -> {
                 stopTutorial.setEnabled(
-                    startTutorial.getValue("TutorialStarted").equals(Boolean.TRUE));
+                    startTutorial.getValue(LABEL_TUTORIAL_STARTED).equals(Boolean.TRUE));
                 startButton.setSelected(stopTutorial.isEnabled());
             };
 
@@ -862,7 +853,7 @@ public class LogUI extends JFrame {
                 }
 
                 if (count == 0) {
-                    startTutorial.putValue("TutorialStarted", Boolean.FALSE);
+                    startTutorial.putValue(LABEL_TUTORIAL_STARTED, Boolean.FALSE);
                 }
             }
         });
@@ -893,7 +884,7 @@ public class LogUI extends JFrame {
                 }
             });
 
-        /**
+        /*
          * loads the saved tab settings and if there are hidden tabs,
          * hide those tabs out of currently loaded tabs..
          */
@@ -1335,7 +1326,7 @@ public class LogUI extends JFrame {
                     panel.setProgress(progress++);
                     Thread.sleep(delay);
                 } catch (Exception e) {
-                    e.printStackTrace();
+                    logger.error(e,e);
                 }
 
                 fireShutdownEvent();
@@ -1344,7 +1335,7 @@ public class LogUI extends JFrame {
             };
 
         if (OSXIntegration.IS_OSX) {
-            /**
+            /*
              * or OSX we do it in the current thread because otherwise returning
              * will exit the process before it's had a chance to save things
              *
@@ -1591,7 +1582,7 @@ public class LogUI extends JFrame {
             thisPanel.setReceiver(rx);
         }
 
-        /**
+        /*
          * Now add the panel as a batch listener so it can handle it's own
          * batchs
          */
@@ -1638,7 +1629,7 @@ public class LogUI extends JFrame {
         getTabbedPane().add(ident, thisPanel);
         getPanelMap().put(ident, thisPanel);
 
-        /**
+        /*
          * Let the new LogPanel receive this batch
          */
 
@@ -1666,11 +1657,8 @@ public class LogUI extends JFrame {
             List<ChainsawLoggingEvent> list = new ArrayList<>();
             Rule rule = ExpressionRule.getRule(ident);
 
-            for (Object identifierPanel : identifierPanels) {
-                LogPanel panel = (LogPanel) identifierPanel;
-
-                for (Object o : panel.getMatchingEvents(rule)) {
-                    LoggingEventWrapper e = (LoggingEventWrapper) o;
+            for (LogPanel identifierPanel : identifierPanels) {
+                for (LoggingEventWrapper e : identifierPanel.getMatchingEvents(rule)) {
                     list.add(e.getLoggingEvent());
                 }
             }
@@ -1823,7 +1811,7 @@ public class LogUI extends JFrame {
             stream.close();
 
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error(e,e);
         }
     }
 }