cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/util/log ExtensiblePatternFormatter.java XMLCocoonLogFormatter.java
Date Thu, 16 Aug 2001 14:02:11 GMT
cziegeler    01/08/16 07:02:11

  Modified:    src/org/apache/cocoon/servlet Tag: cocoon_20_branch
                        CocoonServlet.java
               src/org/apache/cocoon/util/log Tag: cocoon_20_branch
                        ExtensiblePatternFormatter.java
                        XMLCocoonLogFormatter.java
  Log:
  Updated formatter class to new LogKit and added unique request id
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.13.2.16 +6 -3      xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.13.2.15
  retrieving revision 1.13.2.16
  diff -u -r1.13.2.15 -r1.13.2.16
  --- CocoonServlet.java	2001/08/14 16:00:25	1.13.2.15
  +++ CocoonServlet.java	2001/08/16 14:02:11	1.13.2.16
  @@ -45,7 +45,7 @@
   import org.apache.cocoon.util.log.CocoonLogFormatter;
   import org.apache.cocoon.util.log.XMLCocoonLogFormatter;
   import org.apache.log.ContextMap;
  -import org.apache.log.Formatter;
  +import org.apache.log.format.Formatter;
   import org.apache.log.Hierarchy;
   import org.apache.log.LogTarget;
   import org.apache.log.Logger;
  @@ -64,7 +64,7 @@
    * @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.13.2.15 $ $Date: 2001/08/14 16:00:25 $
  + * @version CVS $Revision: 1.13.2.16 $ $Date: 2001/08/16 14:02:11 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -528,9 +528,12 @@
               ContextMap ctxMap = org.apache.log.ContextMap.getCurrentContext();
               ctxMap.clear();
               // Add thread name (default content for empty context)
  -            ctxMap.set("threadName", Thread.currentThread().getName());
  +            String threadName = Thread.currentThread().getName();
  +            ctxMap.set("threadName", threadName);
               // Add the object model
               ctxMap.set("objectModel", env.getObjectModel());
  +            // Add a unique request id (threadName + currentTime
  +            ctxMap.set("request-id", threadName + System.currentTimeMillis());
   
               if (this.cocoon.process(env)) {
                   contentType = env.getContentType();
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.3   +5 -2      xml-cocoon2/src/org/apache/cocoon/util/log/ExtensiblePatternFormatter.java
  
  Index: ExtensiblePatternFormatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/util/log/ExtensiblePatternFormatter.java,v
  retrieving revision 1.3.2.2
  retrieving revision 1.3.2.3
  diff -u -r1.3.2.2 -r1.3.2.3
  --- ExtensiblePatternFormatter.java	2001/08/13 08:41:05	1.3.2.2
  +++ ExtensiblePatternFormatter.java	2001/08/16 14:02:11	1.3.2.3
  @@ -10,7 +10,10 @@
   
   import java.io.StringWriter;
   import java.util.Stack;
  -import org.apache.log.*;
  +import org.apache.log.Hierarchy;
  +import org.apache.log.LogEvent;
  +import org.apache.log.Priority;
  +import org.apache.log.format.Formatter;
   
   /**
    * A refactoring of <code>org.apache.log.format.PatternFormatter</code> that
  @@ -28,7 +31,7 @@
    *
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  - * @version CVS $Revision: 1.3.2.2 $ $Date: 2001/08/13 08:41:05 $
  + * @version CVS $Revision: 1.3.2.3 $ $Date: 2001/08/16 14:02:11 $
    */
   public class ExtensiblePatternFormatter
       implements Formatter
  
  
  
  1.1.2.5   +24 -2     xml-cocoon2/src/org/apache/cocoon/util/log/XMLCocoonLogFormatter.java
  
  Index: XMLCocoonLogFormatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/util/log/XMLCocoonLogFormatter.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- XMLCocoonLogFormatter.java	2001/08/13 08:41:05	1.1.2.4
  +++ XMLCocoonLogFormatter.java	2001/08/16 14:02:11	1.1.2.5
  @@ -13,7 +13,10 @@
   import java.util.Map;
   import java.util.Stack;
   import java.util.StringTokenizer;
  -import org.apache.log.*;
  +import org.apache.log.ContextMap;
  +import org.apache.log.LogEvent;
  +import org.apache.log.Priority;
  +import org.apache.log.format.Formatter;
   import org.apache.avalon.framework.CascadingThrowable;
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.environment.Request;
  @@ -48,7 +51,7 @@
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/08/13 08:41:05 $
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/08/16 14:02:11 $
    */
   public class XMLCocoonLogFormatter
   implements Formatter {
  @@ -92,6 +95,10 @@
       public String format( final LogEvent event ) {
           final StringBuffer sb = new StringBuffer();
           sb.append("<log-entry>").append(EOL);
  +        final String value = this.getRequestId(event.getContextMap());
  +        if (value != null) {
  +            sb.append("<request-id>").append(value).append("</request-id>").append(EOL);
  +        }
           for(int i = 0; i < this.types.length; i++) {
   
               switch(this.types[i]) {
  @@ -189,6 +196,21 @@
                       result = request.getRequestURI();
                   }
               }
  +        }
  +
  +        return result;
  +    }
  +
  +    /**
  +     * Find the request id that is being processed.
  +     */
  +    private String getRequestId(ContextMap ctxMap) {
  +        String result = null;
  +
  +        // Get URI from the the object model.
  +        if (ctxMap != null) {
  +            Object context = ctxMap.get("request-id");
  +            if (context != null) result = context.toString();
           }
   
           return result;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message