costin      2003/01/10 21:12:48

  Modified:    catalina/src/share/org/apache/catalina/valves
                        AccessLogValve.java
  Log:
  I did that long ago - it just add %D to display the time in millis
  ( like in apache )
  Usefull for people with fast servlets :-)
  
  Revision  Changes    Path
  1.3       +13 -5     
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java
  
  Index: AccessLogValve.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AccessLogValve.java       22 Nov 2002 22:23:44 -0000      1.2
  +++ AccessLogValve.java       11 Jan 2003 05:12:48 -0000      1.3
  @@ -118,7 +118,8 @@
    * <li><b>%u</b> - Remote user that was authenticated
    * <li><b>%U</b> - Requested URL path
    * <li><b>%v</b> - Local server name
  - * </ul>
  + * <li><b>%D</b> - Time taken to process the request, in millis
  +  * </ul>
    * <p>In addition, the caller can specify one of the following aliases for
    * commonly utilized patterns:</p>
    * <ul>
  @@ -506,8 +507,13 @@
           throws IOException, ServletException {
   
           // Pass this request on to the next valve in our pipeline
  +        long t1=System.currentTimeMillis();
  +
           context.invokeNext(request, response);
   
  +        long t2=System.currentTimeMillis();
  +        long time=t2-t1;
  +
           Date date = getDate();
           StringBuffer result = new StringBuffer();
   
  @@ -617,10 +623,10 @@
                           } else {
                               //D'oh - end of string - pretend we never did this
                               //and do processing the "old way"
  -                            result.append(replace(ch, date, request, response));
  +                            result.append(replace(ch, date, request, response, 
time));
                           }
                       } else {
  -                        result.append(replace(ch, date, request, response));
  +                        result.append(replace(ch, date, request, response,time ));
                       }
                       replace = false;
                   } else if (ch == '%') {
  @@ -756,7 +762,7 @@
        * @param response Response being processed
        */
       private String replace(char pattern, Date date, Request request,
  -                           Response response) {
  +                           Response response, long time) {
   
           String value = null;
   
  @@ -798,6 +804,8 @@
                   value = "";
           } else if (pattern == 'p') {
               value = "" + req.getServerPort();
  +        } else if (pattern == 'D') {
  +                    value = "" + time;
           } else if (pattern == 'q') {
               String query = null;
               if (hreq != null)
  
  
  

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

Reply via email to