harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r434332 - in /incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging: LogManager.java Logger.java
Date Thu, 24 Aug 2006 07:44:16 GMT
Author: pyang
Date: Thu Aug 24 00:44:16 2006
New Revision: 434332

URL: http://svn.apache.org/viewvc?rev=434332&view=rev
Log:
Fix multiple bugs of LogManager and Logger, including the default logger initialization time,
the usage of parent level/handler, etc. 

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java?rev=434332&r1=434331&r2=434332&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
Thu Aug 24 00:44:16 2006
@@ -186,7 +186,7 @@
 
         // read configuration
         try {
-            manager.readConfiguration();
+            manager.readConfigurationImpl(true);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -394,7 +394,7 @@
      *             not have the required permissions to perform this action
      */
     public void readConfiguration() throws IOException {
-        readConfigurationImpl();
+        readConfigurationImpl(false);
     }
 
     // use privilege code to get system property
@@ -425,7 +425,7 @@
     }
 
     // actual default initialization process
-    private synchronized void readConfigurationImpl() throws IOException {
+    private synchronized void readConfigurationImpl(boolean createLoggers) throws IOException
{
         checkAccess();
         boolean needInit = true;
 
@@ -451,7 +451,7 @@
             InputStream input = null;
             try {
                 input = new BufferedInputStream(new FileInputStream(configFile));
-                readConfigurationImpl(input);
+                readConfigurationImpl(input, createLoggers);
             } finally {
                 try {
                     input.close();
@@ -462,42 +462,38 @@
     }
 
     // actual initialization process from a given input stream
-    private synchronized void readConfigurationImpl(InputStream ins)
+    private synchronized void readConfigurationImpl(InputStream ins, boolean createLoggers)
             throws IOException {
         reset();
-        if(manager.root == null){
-            // init root logger
-            manager.root = new Logger("", null); //$NON-NLS-1$
-            manager.loggers.put("", manager.root); //$NON-NLS-1$
-            root.manager = this;
-        }
         props.load(ins);
 
         // configs
         parseConfigProp();
 
         // set levels for logger
-        initLevelForLoggers();
+        initLoggers(createLoggers);
         listeners.firePropertyChange(null, null, null);
     }
 
     // init "level" properties for all registered loggers
-    private void initLevelForLoggers() {
+    private void initLoggers(boolean createLoggers) {
         Enumeration<?> enumeration = props.propertyNames();
         while (enumeration.hasMoreElements()) {
             // search for all properties whose name is ended with ".level"
-            String loggerLevel = (String) enumeration.nextElement();
-            if (!loggerLevel.endsWith(".level")) { //$NON-NLS-1$
-                continue;
-            }
-            // if find such properties, search for relevant registered logger
-            String loggerName = loggerLevel.substring(0,
-                    loggerLevel.length() - 6);
-            Logger l = loggers.get(loggerName);
-            if (null == l) {
-                continue;
+            String property = (String) enumeration.nextElement();
+            if (property.endsWith(".level")) { //$NON-NLS-1$
+                String loggerName = property.substring(0,
+                        property.length() - ".level".length());
+                Logger l = createLoggers?Logger.getLogger(loggerName):loggers.get(loggerName);
+                if (null != l) {
+                    setLoggerLevel(l, loggerName, true);
+                }
+            }else if(createLoggers && property.endsWith(".handlers")){ //$NON-NLS-1$
+                String loggerName = property.substring(0,
+                        property.length() - ".handlers".length());
+                Logger.getLogger(loggerName);
+                //lazily load handlers because some of them are expensive
             }
-            setLoggerLevel(l, loggerName, true);
         }
     }
 
@@ -530,7 +526,7 @@
      */
     public void readConfiguration(InputStream ins) throws IOException {
         checkAccess();
-        readConfigurationImpl(ins);
+        readConfigurationImpl(ins, false);
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java?rev=434332&r1=434331&r2=434332&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
Thu Aug 24 00:44:16 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -434,7 +434,7 @@
               return;
           }
           handlers = new ArrayList<Handler>();
-          String handlerStr = manager.getProperty(name==""?"handlers":name+".handlers");
//$NON-NLS-1$
+          String handlerStr = manager.getProperty("".equals(name)?"handlers":name+".handlers");
//$NON-NLS-1$
           if (null == handlerStr) {
               return;
           }



Mime
View raw message