sebb        2004/03/21 04:05:34

  Modified:    src/jorphan/org/apache/jorphan/logging LoggingManager.java
  Log:
  Oops! forgot that JMeterUtils is not available to classes in Jorphan.
  
  Revision  Changes    Path
  1.12      +54 -38    
jakarta-jmeter/src/jorphan/org/apache/jorphan/logging/LoggingManager.java
  
  Index: LoggingManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/jorphan/org/apache/jorphan/logging/LoggingManager.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LoggingManager.java       20 Mar 2004 14:49:58 -0000      1.11
  +++ LoggingManager.java       21 Mar 2004 12:05:34 -0000      1.12
  @@ -24,7 +24,6 @@
   import java.util.Iterator;
   import java.util.Properties;
   
  -import org.apache.jmeter.util.JMeterUtils;
   import org.apache.jorphan.util.ClassContext;
   import org.apache.log.Hierarchy;
   import org.apache.log.LogTarget;
  @@ -35,8 +34,7 @@
   import org.apache.log.output.io.WriterTarget;
   
   /**
  - * @author Michael Stover (mstover1 at apache.org)
  - * @version $Revision$
  + * @version $Revision$ on $Date$
    */
   public final class LoggingManager
   {
  @@ -58,39 +56,8 @@
                "%{time:yyyy/MM/dd HH:mm:ss} %5.5{priority} "
           + "%{category}[%{thread}]: %{message} %{throwable}";
   
  -     private static PatternFormatter getFormat()
  -     {
  -             if (savedFormat == null)
  -             {
  -                     String pattern = DEFAULT_PATTERN;
  -                     String type = JMeterUtils.getPropDefault("log_format_type","");
  -                     if (type.length()==0)
  -                     {
  -                             
pattern=JMeterUtils.getPropDefault("log_format",DEFAULT_PATTERN);
  -                     }
  -                     else
  -                     {
  -                             if (type.equalsIgnoreCase("thread_suffix"))
  -                             {
  -                                     pattern=PATTERN_THREAD_SUFFIX;
  -                             }
  -                             else 
  -                             if (type.equalsIgnoreCase("thread_prefix"))
  -                             {
  -                                     pattern=PATTERN_THREAD_PREFIX;
  -                             }
  -                             else
  -                             {
  -                                     pattern=DEFAULT_PATTERN;
  -                             }
  -                     }
  -                     savedFormat = new PatternFormatter(pattern+"\n");
  -             }
  -             return savedFormat;
  -     }
  -
   
  -     private static PatternFormatter savedFormat = null;
  +     private static PatternFormatter format = null;
        
       /** Used to hold the default logging target. */
       private static LogTarget target;
  @@ -130,6 +97,8 @@
               logManager = new LoggingManager();
           }
   
  +        setFormat(properties);
  +        
           // Set the top-level defaults
           setTarget(
               makeWriter(
  @@ -141,6 +110,48 @@
           // now set the individual categories (if any)
       }
   
  +     private static void setFormat(Properties properties)
  +     {
  +                     String pattern = DEFAULT_PATTERN;
  +                     String type = properties.getProperty("log_format_type","");
  +                     if (type.length()==0)
  +                     {
  +                             
pattern=properties.getProperty("log_format",DEFAULT_PATTERN);
  +                     }
  +                     else
  +                     {
  +                             if (type.equalsIgnoreCase("thread_suffix"))
  +                             {
  +                                     pattern=PATTERN_THREAD_SUFFIX;
  +                             }
  +                             else 
  +                             if (type.equalsIgnoreCase("thread_prefix"))
  +                             {
  +                                     pattern=PATTERN_THREAD_PREFIX;
  +                             }
  +                             else
  +                             {
  +                                     pattern=DEFAULT_PATTERN;
  +                             }
  +                     }
  +                     format = new PatternFormatter(pattern+"\n");
  +     }
  +
  +
  +     /*
  +      * Helper method to ensure that format is initialised if initializeLogging()
  +      * has not yet been called.
  +     */
  +     private static PatternFormatter getFormat()
  +     {
  +     if (format == null)
  +     {
  +            format = new PatternFormatter(DEFAULT_PATTERN+"\n");             
  +     }
  +     return format;
  +    }
  +    
  +
       /*
        * Helper method to handle log target creation.
        * If there is an error creating the file, then it uses System.out.
  @@ -259,7 +270,7 @@
       {
           if (target == null)
           {
  -            target = new WriterTarget(targetFile, getFormat());
  +            target = getTarget(targetFile, getFormat());
               isTargetSystemOut=isWriterSystemOut;
           }
           else
  @@ -268,9 +279,14 @@
               {
                   ((WriterTarget) target).close();
               }
  -            target = new WriterTarget(targetFile, getFormat());
  +            target = getTarget(targetFile, getFormat());
                        isTargetSystemOut=isWriterSystemOut;
           }
           Hierarchy.getDefaultHierarchy().setDefaultLogTarget(target);
  +    }
  +    
  +    private static LogTarget getTarget(Writer targetFile, PatternFormatter fmt)
  +     {
  +     return new WriterTarget(targetFile, fmt);
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to