sebb        2004/06/19 08:45:01

  Modified:    src/functions/org/apache/jmeter/functions Tag: rel-2_0
                        LogFunction2.java LogFunction.java
               xdocs/usermanual Tag: rel-2_0 functions.xml
  Log:
  Add OUT and ERR pseudo log level names to __log() functions
  These print output on System.out or System.err instead of the log file
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.3.2.1   +3 -7      
jakarta-jmeter/src/functions/org/apache/jmeter/functions/LogFunction2.java
  
  Index: LogFunction2.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/functions/org/apache/jmeter/functions/LogFunction2.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- LogFunction2.java 30 Mar 2004 18:07:07 -0000      1.3
  +++ LogFunction2.java 19 Jun 2004 15:45:01 -0000      1.3.2.1
  @@ -28,7 +28,6 @@
   import org.apache.jmeter.samplers.Sampler;
   import org.apache.jorphan.logging.LoggingManager;
   import org.apache.log.Logger;
  -import org.apache.log.Priority;
   
   /**
    * Function to log a message
  @@ -90,11 +89,8 @@
                if (values.length > 2){ // Throwable wanted
                        t = new Throwable(((CompoundVariable) values[2]).execute());
                }
  -             
  -             // N.B. if the string is not recognised, DEBUG is assumed
  -        Priority p = Priority.getPriorityForName(priorityString);
   
  -        log.log(p,stringToLog,t);
  +             LogFunction.logDetails(log,stringToLog,priorityString,t);
           
           return "";
   
  
  
  
  1.3.2.1   +40 -7     
jakarta-jmeter/src/functions/org/apache/jmeter/functions/LogFunction.java
  
  Index: LogFunction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/functions/org/apache/jmeter/functions/LogFunction.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- LogFunction.java  30 Mar 2004 18:07:07 -0000      1.3
  +++ LogFunction.java  19 Jun 2004 15:45:01 -0000      1.3.2.1
  @@ -91,13 +91,46 @@
                        t = new Throwable(((CompoundVariable) values[2]).execute());
                }
                
  -             // N.B. if the string is not recognised, DEBUG is assumed
  -        Priority p = Priority.getPriorityForName(priorityString);
  -
  -        log.log(p,stringToLog,t);
  -        
  +             logDetails(log,stringToLog,priorityString,t);
  +             
           return stringToLog;
   
  +    }
  +
  +    // Common output function
  +    private static void printDetails(java.io.PrintStream ps,String s, Throwable t)
  +    {
  +             String tn = Thread.currentThread().getName();
  +             if (t != null)
  +             {
  +                     ps.print("Log: "+ tn + " : " + s + " ");
  +                     t.printStackTrace(ps);
  +             }
  +             else
  +             {
  +                     ps.println("Log: "+ tn + " : " + s);
  +             }
  +    }
  +    
  +    // Routine to perform the output (also used by __logn() function)
  +    static void logDetails(Logger l,String s,String prio,Throwable t)
  +    {
  +             if (prio.equalsIgnoreCase("OUT")) //$NON-NLS-1
  +             {
  +                     printDetails(System.out,s,t);
  +             }
  +             else 
  +             if (prio.equalsIgnoreCase("ERR")) //$NON-NLS-1
  +             {
  +                     printDetails(System.err,s,t);
  +             }
  +             else
  +             {
  +                     // N.B. if the string is not recognised, DEBUG is assumed
  +                     Priority p = Priority.getPriorityForName(prio);
  +            log.log(p,s,t);
  +             }
  +     
       }
   
       public void setParameters(Collection parameters)
  
  
  
  No                   revision
  No                   revision
  1.14.2.4  +11 -5     jakarta-jmeter/xdocs/usermanual/functions.xml
  
  Index: functions.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/xdocs/usermanual/functions.xml,v
  retrieving revision 1.14.2.3
  retrieving revision 1.14.2.4
  diff -u -r1.14.2.3 -r1.14.2.4
  --- functions.xml     18 Jun 2004 16:25:39 -0000      1.14.2.3
  +++ functions.xml     19 Jun 2004 15:45:01 -0000      1.14.2.4
  @@ -105,7 +105,7 @@
   </p></description>
   
   <properties>
  -        <property name="First arguement" required="Yes">The first argument is the 
regular expression
  +        <property name="First argument" required="Yes">The first argument is the 
regular expression
           to be applied to the response data.  It will grab all matches.  Any parts 
of this expression
           that you wish to use in your template string, be sure to surround in 
parentheses.  Example:
           &amp;lt;a href="(.*)"&amp;gt;.  This will grab the value of the link and 
store it as the first group (there is
  @@ -381,9 +381,12 @@
   
   <properties>
           <property name="String to be logged" required="Yes">A string</property>
  -        <property name="Log Level" required="No">DEBUG, INFO (default), WARN or 
ERROR</property>
  +        <property name="Log Level" required="No">OUT, ERR, DEBUG, INFO (default), 
WARN or ERROR</property>
           <property name="Throwable text" required="No">If non-empty, creates a 
Throwable to pass to the logger</property>
   </properties>
  +<p>The OUT and ERR log level names are used to direct the output to System.out and 
System.err respectively.
  +     In this case, the output is always printed - it does not depend on the current 
log setting.
  +</p>
   </component>
   
   <component index="16.5.12" name="__logn">
  @@ -395,9 +398,12 @@
   
   <properties>
           <property name="String to be logged" required="Yes">A string</property>
  -        <property name="Log Level" required="No">DEBUG, INFO (default), WARN or 
ERROR</property>
  +        <property name="Log Level" required="No">OUT, ERR, DEBUG, INFO (default), 
WARN or ERROR</property>
           <property name="Throwable text" required="No">If non-empty, creates a 
Throwable to pass to the logger</property>
   </properties>
  +<p>The OUT and ERR log level names are used to direct the output to System.out and 
System.err respectively.
  +     In this case, the output is always printed - it does not depend on the current 
log setting.
  +</p>
   </component>
   
   <component index="16.5.13" name="__BeanShell">
  
  
  

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

Reply via email to