Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 29443 invoked from network); 24 Aug 2006 07:44:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Aug 2006 07:44:38 -0000 Received: (qmail 22918 invoked by uid 500); 24 Aug 2006 07:44:38 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 22894 invoked by uid 500); 24 Aug 2006 07:44:38 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 22883 invoked by uid 99); 24 Aug 2006 07:44:38 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Aug 2006 00:44:38 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Aug 2006 00:44:37 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 56BCB1A981D; Thu, 24 Aug 2006 00:44:17 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: harmony-commits@incubator.apache.org From: pyang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060824074417.56BCB1A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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(); - 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; }