hello all,

the attached patch --already committed-- fixes a minor bug with the 
FileHandler class related to correct handling of the pattern property.

2006-05-28  Raif S. Naffah  <[EMAIL PROTECTED]>

        * java/util/logging/FileHandler.java (PROPERTY_PREFIX): New constant.
        (PATTERN_KEY): Likewise.
        (DEFAULT_PATTERN): Likewise.
        (LIMIT_KEY): Likewise.
        (DEFAULT_LIMIT): Likewise.
        (COUNT_KEY): Likewise.
        (DEFAULT_COUNT): Likewise.
        (APPEND_KEY): Likewise.
        (DEFAULT_APPEND): Likewise.
        (FileHandler()): Use pattern value as set in logging.properties.
        Use constants defined above.
        (FileHandler(1)): Use constants defined above.
        (FileHandler(2)): Likewise.
        (FileHandler(3)): Likewise.
        (FileHandler(4)): Likewise.
        (createFileStream): Likewise.

cheers;
rsn
Index: FileHandler.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/logging/FileHandler.java,v
retrieving revision 1.13
diff -u -r1.13 FileHandler.java
--- FileHandler.java	28 May 2006 08:58:32 -0000	1.13
+++ FileHandler.java	28 May 2006 09:55:51 -0000
@@ -192,6 +192,42 @@
   extends StreamHandler
 {
   /**
+   * A literal that prefixes all file-handler related properties in the
+   * logging.properties file.
+   */
+  private static final String PROPERTY_PREFIX = "java.util.logging.FileHandler";
+  /**
+   * The name of the property to set for specifying a file naming (incl. path)
+   * pattern to use with rotating log files.
+   */
+  private static final String PATTERN_KEY = PROPERTY_PREFIX + ".pattern";
+  /**
+   * The default pattern to use when the <code>PATTERN_KEY</code> property was
+   * not specified in the logging.properties file.
+   */
+  private static final String DEFAULT_PATTERN = "%h/java%u.log";
+  /**
+   * The name of the property to set for specifying an approximate maximum
+   * amount, in bytes, to write to any one log output file. A value of zero
+   * (which is the default) implies a no limit.
+   */
+  private static final String LIMIT_KEY = PROPERTY_PREFIX + ".limit";
+  private static final int DEFAULT_LIMIT = 0;
+  /**
+   * The name of the property to set for specifying how many output files to
+   * cycle through. The default value is 1.
+   */
+  private static final String COUNT_KEY = PROPERTY_PREFIX + ".count";
+  private static final int DEFAULT_COUNT = 1;
+  /**
+   * The name of the property to set for specifying whether this handler should
+   * append, or not, its output to existing files. The default value is
+   * <code>false</code> meaning NOT to append.
+   */
+  private static final String APPEND_KEY = PROPERTY_PREFIX + ".append";
+  private static final boolean DEFAULT_APPEND = false;
+
+  /**
    * The number of bytes a log file is approximately allowed to reach
    * before it is closed and the handler switches to the next file in
    * the rotating set.  A value of zero means that files can grow
@@ -252,16 +288,10 @@
   public FileHandler()
     throws IOException, SecurityException
   {
-    this(/* pattern: use configiguration */ null,
-
-	 LogManager.getIntProperty("java.util.logging.FileHandler.limit",
-				   /* default */ 0),
-
-	 LogManager.getIntProperty("java.util.logging.FileHandler.count",
-				   /* default */ 1),
-
-	 LogManager.getBooleanProperty("java.util.logging.FileHandler.append",
-				       /* default */ false));
+    this(LogManager.getLogManager().getProperty(PATTERN_KEY),
+	 LogManager.getIntProperty(LIMIT_KEY, DEFAULT_LIMIT),
+	 LogManager.getIntProperty(COUNT_KEY, DEFAULT_COUNT),
+	 LogManager.getBooleanProperty(APPEND_KEY, DEFAULT_APPEND));
   }
 
 
@@ -269,10 +299,7 @@
   public FileHandler(String pattern)
     throws IOException, SecurityException
   {
-    this(pattern,
-	 /* limit */ 0,
-	 /* count */ 1,
-	 /* append */ false);
+    this(pattern, DEFAULT_LIMIT, DEFAULT_COUNT, DEFAULT_APPEND);
   }
 
 
@@ -280,10 +307,7 @@
   public FileHandler(String pattern, boolean append)
     throws IOException, SecurityException
   {
-    this(pattern,
-	 /* limit */ 0,
-	 /* count */ 1,
-	 append);
+    this(pattern, DEFAULT_LIMIT, DEFAULT_COUNT, append);
   }
 
 
@@ -292,9 +316,7 @@
     throws IOException, SecurityException
   {
     this(pattern, limit, count, 
-	 LogManager.getBooleanProperty(
-	   "java.util.logging.FileHandler.append",
-	   /* default */ false));
+	 LogManager.getBooleanProperty(APPEND_KEY, DEFAULT_APPEND));
   }
 
 
@@ -350,7 +372,7 @@
     throws IOException, SecurityException
   {
     super(/* output stream, created below */ null,
-	  "java.util.logging.FileHandler",
+	  PROPERTY_PREFIX,
 	  /* default level */ Level.ALL,
 	  /* formatter */ null,
 	  /* default formatter */ XMLFormatter.class);
@@ -389,10 +411,9 @@
      * LogManager configuration property.
      */
     if (pattern == null)
-      pattern = LogManager.getLogManager().getProperty(
-                              "java.util.logging.FileHandler.pattern");
+      pattern = LogManager.getLogManager().getProperty(PATTERN_KEY);
     if (pattern == null)
-      pattern = "%h/java%u.log";
+      pattern = DEFAULT_PATTERN;
 
     if (count > 1 && !has (pattern, 'g'))
       pattern = pattern + ".%g";

Attachment: pgpeAgXVqCKs1.pgp
Description: PGP signature

Reply via email to