cziegeler    01/08/13 01:40:38

  Modified:    src/org/apache/cocoon/servlet CocoonServlet.java
               src/org/apache/cocoon/util/log CocoonLogFormatter.java
                        ExtensiblePatternFormatter.java
                        XMLCocoonLogFormatter.java
  Added:       lib      logkit-1.0b4.jar
  Removed:     lib      logkit-1.0b3.jar
  Log:
  Updated to LogKit B4
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/lib/logkit-1.0b4.jar
  
        <<Binary file>>
  
  
  1.28      +8 -9      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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- CocoonServlet.java        2001/08/10 12:20:02     1.27
  +++ CocoonServlet.java        2001/08/13 08:40:38     1.28
  @@ -44,14 +44,14 @@
   import org.apache.cocoon.util.NetUtils;
   import org.apache.cocoon.util.log.CocoonLogFormatter;
   import org.apache.cocoon.util.log.XMLCocoonLogFormatter;
  -import org.apache.log.ContextStack;
  +import org.apache.log.ContextMap;
   import org.apache.log.Formatter;
   import org.apache.log.Hierarchy;
   import org.apache.log.LogTarget;
   import org.apache.log.Logger;
   import org.apache.log.Priority;
   import org.apache.log.filter.PriorityFilter;
  -import org.apache.log.output.FileOutputLogTarget;
  +import org.apache.log.output.io.FileTarget;
   import org.apache.log.output.ServletOutputLogTarget;
   import org.xml.sax.SAXException;
   
  @@ -64,7 +64,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.27 $ $Date: 2001/08/10 12:20:02 $
  + * @version CVS $Revision: 1.28 $ $Date: 2001/08/13 08:40:38 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -377,10 +377,9 @@
               this.log = Hierarchy.getDefaultHierarchy().getLoggerFor("cocoon");
               this.log.setPriority(logPriority);
   
  -            FileOutputLogTarget fileTarget = new FileOutputLogTarget(path);
  +            FileTarget fileTarget = new FileTarget(new File(path), false, 
formatter);
               ServletOutputLogTarget servTarget = new 
ServletOutputLogTarget(this.servletContext);
   
  -            fileTarget.setFormatter(formatter);
               servTarget.setFormatter(formatter);
   
               PriorityFilter filter = new PriorityFilter(Priority.ERROR);
  @@ -525,12 +524,12 @@
   
               // Initialize a fresh log context containing the object model : it
               // will be used by the CocoonLogFormatter
  -            ContextStack ctxStack = org.apache.log.ContextStack.getCurrentContext();
  -            ctxStack.clear();
  +            ContextMap ctxMap = org.apache.log.ContextMap.getCurrentContext();
  +            ctxMap.clear();
               // Add thread name (default content for empty context)
  -            ctxStack.push(Thread.currentThread().getName());
  +            ctxMap.set("threadName", Thread.currentThread().getName());
               // Add the object model
  -            ctxStack.push(env.getObjectModel());
  +            ctxMap.set("objectModel", env.getObjectModel());
   
               if (this.cocoon.process(env)) {
                   processed = true;
  
  
  
  1.5       +13 -14    
xml-cocoon2/src/org/apache/cocoon/util/log/CocoonLogFormatter.java
  
  Index: CocoonLogFormatter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/util/log/CocoonLogFormatter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CocoonLogFormatter.java   2001/08/13 05:57:32     1.4
  +++ CocoonLogFormatter.java   2001/08/13 08:40:38     1.5
  @@ -17,7 +17,7 @@
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.environment.Request;
   
  -import org.apache.log.ContextStack;
  +import org.apache.log.ContextMap;
   import org.apache.log.LogEvent;
   
   /**
  @@ -34,7 +34,7 @@
    * </ul>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Revision: 1.4 $ $Date: 2001/08/13 05:57:32 $
  + * @version CVS $Revision: 1.5 $ $Date: 2001/08/13 08:40:38 $
    */
   
   public class CocoonLogFormatter extends ExtensiblePatternFormatter
  @@ -101,10 +101,10 @@
                   return getClass(run.m_format);
                   
               case TYPE_URI :
  -                return getURI(event.getContextStack());
  +                return getURI(event.getContextMap());
                   
               case TYPE_THREAD :
  -                return getThread(event.getContextStack());
  +                return getThread(event.getContextMap());
           }
           
           return super.formatPatternRun(event, run);
  @@ -144,14 +144,13 @@
       /**
        * Find the URI that is being processed.
        */
  -    
  -    private String getURI(ContextStack ctxStack) {
  +    private String getURI(ContextMap ctxMap) {
           String result = "Unknown-URI";
           
  -        // Get URI from the first context stack element, if it's a Map (the object 
model).
  -        if (ctxStack.getSize() > 1) {
  -            Object context = ctxStack.get(1);
  -            if (context instanceof Map) {
  +        // Get URI from the the object model.
  +        if (ctxMap != null) {
  +            Object context = ctxMap.get("objectModel");
  +            if (context != null && context instanceof Map) {
                   // Get the request
                   Request request = 
(Request)((Map)context).get(Constants.REQUEST_OBJECT);
                   if (request != null) {
  @@ -163,13 +162,13 @@
           return result;
       }
       
  +
       /**
        * Find the thread that is logged this event.
        */
  -    
  -    private String getThread(ContextStack ctxStack) {
  -        if (ctxStack.getSize() > 0)
  -            return String.valueOf(ctxStack.get(0));
  +    private String getThread(ContextMap ctxMap) {
  +        if (ctxMap != null && ctxMap.get("threadName") != null)
  +            return (String)ctxMap.get("threadName");
           else
               return "Unknown-thread";
       }
  
  
  
  1.4       +1 -43     
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
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExtensiblePatternFormatter.java   2001/08/07 15:07:02     1.3
  +++ ExtensiblePatternFormatter.java   2001/08/13 08:40:38     1.4
  @@ -28,14 +28,13 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Donald</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/08/07 15:07:02 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/08/13 08:40:38 $
    */
   public class ExtensiblePatternFormatter
       implements Formatter
   {
       protected final static int         TYPE_TEXT            = 1;
       protected final static int         TYPE_CATEGORY        = 2;
  -    protected final static int         TYPE_CONTEXT         = 3;
       protected final static int         TYPE_MESSAGE         = 4;
       protected final static int         TYPE_TIME            = 5;
       protected final static int         TYPE_RELATIVE_TIME   = 6;
  @@ -50,7 +49,6 @@
        
   
       protected final static String      TYPE_CATEGORY_STR      = "category";
  -    protected final static String      TYPE_CONTEXT_STR       = "context";
       protected final static String      TYPE_MESSAGE_STR       = "message";
       protected final static String      TYPE_TIME_STR          = "time";
       protected final static String      TYPE_RELATIVE_TIME_STR = "rtime";
  @@ -369,10 +367,6 @@
                   str = getMessage( event.getMessage(), run.m_format );
                   break;
   
  -            case TYPE_CONTEXT:
  -                str = getContext( event.getContextStack(), run.m_format );
  -                break;
  -
               case TYPE_CATEGORY:
                   str = getCategory( event.getCategory(), run.m_format );
                   break;
  @@ -410,41 +404,6 @@
       }
   
       /**
  -     * Utility method to format context.
  -     *
  -     * @param context the context string
  -     * @param format ancilliary format parameter - allowed to be null
  -     * @return the formatted string
  -     */
  -    protected String getContext( final ContextStack stack, final String format )
  -    {
  -        //TODO: Retrieve StringBuffers from a cache
  -        final StringBuffer sb = new StringBuffer();
  -        final int size = stack.getSize();
  -
  -        int sizeSpecification = Integer.MAX_VALUE;
  -
  -        if( null != format )
  -        {
  -            try { sizeSpecification = Integer.parseInt( format ); }
  -            catch( final NumberFormatException nfe ) { nfe.printStackTrace(); }
  -        }
  -
  -        final int end = size - 1;
  -        final int start = Math.max( end - sizeSpecification + 1, 0 );
  -
  -        for( int i = start; i < end; i++ )
  -        {
  -            sb.append( fix( stack.get( i ).toString() ) );
  -            sb.append( '.' );
  -        }
  -
  -        sb.append( stack.get( end ) );
  -
  -        return sb.toString();
  -    }
  -
  -    /**
        * Correct a context string by replacing '.''s with a '_'.
        *
        * @param context the un-fixed context
  @@ -503,7 +462,6 @@
       protected int getTypeIdFor( final String type )
       {
           if( type.equalsIgnoreCase( TYPE_CATEGORY_STR ) ) return TYPE_CATEGORY;
  -        else if( type.equalsIgnoreCase( TYPE_CONTEXT_STR ) ) return TYPE_CONTEXT;
           else if( type.equalsIgnoreCase( TYPE_MESSAGE_STR ) ) return TYPE_MESSAGE;
           else if( type.equalsIgnoreCase( TYPE_PRIORITY_STR ) ) return TYPE_PRIORITY;
           else if( type.equalsIgnoreCase( TYPE_TIME_STR ) ) return TYPE_TIME;
  
  
  
  1.5       +27 -46    
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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLCocoonLogFormatter.java        2001/08/13 05:57:32     1.4
  +++ XMLCocoonLogFormatter.java        2001/08/13 08:40:38     1.5
  @@ -38,7 +38,6 @@
    *     element.</li>
    * <li><code>uri</code> : outputs the request URI (&lt;uri&gt;).<li>
    * <li><code>category</code> : outputs the log category (&lt;category&gt;).<li>
  - * <li><code>context</code> : outputs the context (&lt;context-stack&gt;).<li>
    * <li><code>message</code> : outputs the message (&lt;message&gt;).<li>
    * <li><code>time</code> : outputs the time (&lt;time&gt;).<li>
    * <li><code>rtime</code> : outputs the relative time (&lt;relative-time&gt;).<li>
  @@ -49,7 +48,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Donald</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.4 $ $Date: 2001/08/13 05:57:32 $
  + * @version CVS $Revision: 1.5 $ $Date: 2001/08/13 08:40:38 $
    */
   public class XMLCocoonLogFormatter
   implements Formatter {
  @@ -59,27 +58,25 @@
   
       protected final static int         TYPE_REQUEST_URI     = 0;
       protected final static int         TYPE_CATEGORY        = 1;
  -    protected final static int         TYPE_CONTEXT         = 2;
  -    protected final static int         TYPE_MESSAGE         = 3;
  -    protected final static int         TYPE_TIME            = 4;
  -    protected final static int         TYPE_RELATIVE_TIME   = 5;
  -    protected final static int         TYPE_THROWABLE       = 6;
  -    protected final static int         TYPE_PRIORITY        = 7;
  -    protected final static int         TYPE_CLASS        = 8;
  -    protected final static int         TYPE_CLASS_SHORT        = 9;
  -    protected final static int         TYPE_THREAD        = 10;
  +    protected final static int         TYPE_MESSAGE         = 2;
  +    protected final static int         TYPE_TIME            = 3;
  +    protected final static int         TYPE_RELATIVE_TIME   = 4;
  +    protected final static int         TYPE_THROWABLE       = 5;
  +    protected final static int         TYPE_PRIORITY        = 6;
  +    protected final static int         TYPE_CLASS        = 7;
  +    protected final static int         TYPE_CLASS_SHORT        = 8;
  +    protected final static int         TYPE_THREAD        = 9;
   
       public final static String[] typeStrings = new String[] {"uri", // 0
            "category",  // 1
  -         "context",   // 2
  -         "message",   // 3
  -         "time",      // 4
  -         "rtime",     // 5
  -         "throwable", // 6
  -         "priority",  // 7
  -         "class",    // 8
  -         "class:short", // 9
  -         "thread"};  // 10
  +         "message",   // 2
  +         "time",      // 3
  +         "rtime",     // 4
  +         "throwable", // 5
  +         "priority",  // 6
  +         "class",    // 7
  +         "class:short", // 8
  +         "thread"};  // 9
   
       protected final static String EOL = System.getProperty("line.separator", "\n");
       protected final SimpleDateFormat dateFormatter = new 
SimpleDateFormat("(yyyy-MM-dd) HH:mm.ss:SSS");
  @@ -101,7 +98,7 @@
   
                   case TYPE_REQUEST_URI:
                       sb.append("<uri>");
  -                    sb.append(this.getURI(event.getContextStack()));
  +                    sb.append(this.getURI(event.getContextMap()));
                       sb.append("</uri>").append(EOL);
                       break;
   
  @@ -118,7 +115,7 @@
   
                   case TYPE_THREAD:
                       sb.append("<thread>");
  -                    sb.append(this.getThread(event.getContextStack()));
  +                    sb.append(this.getThread(event.getContextMap()));
                       sb.append("</thread>").append(EOL);
                       break;
   
  @@ -158,20 +155,6 @@
                       sb.append(EOL).append("]]> </message>").append(EOL);
                       break;
   
  -                case TYPE_CONTEXT:
  -                    sb.append("<context-stack>");
  -                    final ContextStack stack = event.getContextStack();
  -                    final int size = stack.getSize();
  -
  -                    for( int cs = 0; cs < size-1; cs++ ) {
  -                        sb.append(stack.get( cs ));
  -                        sb.append( '.' );
  -                    }
  -
  -                    sb.append( stack.get( size-1 ) );
  -                    sb.append("</context-stack>").append(EOL);
  -                    break;
  -
                   case TYPE_CATEGORY:
                       sb.append("<category>");
                       sb.append(event.getCategory());
  @@ -193,14 +176,13 @@
       /**
        * Find the URI that is being processed.
        */
  -
  -    private String getURI(ContextStack ctxStack) {
  +    private String getURI(ContextMap ctxMap) {
           String result = "Unknown-URI";
   
  -        // Get URI from the first context stack element, if it's a Map (the object 
model).
  -        if (ctxStack.getSize() > 1) {
  -            Object context = ctxStack.get(1);
  -            if (context instanceof Map) {
  +        // Get URI from the the object model.
  +        if (ctxMap != null) {
  +            Object context = ctxMap.get("objectModel");
  +            if (context != null &&context instanceof Map) {
                   // Get the request
                   Request request = 
(Request)((Map)context).get(Constants.REQUEST_OBJECT);
                   if (request != null) {
  @@ -246,10 +228,9 @@
       /**
        * Find the thread that is logged this event.
        */
  -
  -    private String getThread(ContextStack ctxStack) {
  -        if (ctxStack.getSize() > 0)
  -            return String.valueOf(ctxStack.get(0));
  +    private String getThread(ContextMap ctxMap) {
  +        if (ctxMap != null&& ctxMap.get("threadName") != null)
  +            return (String)ctxMap.get("threadName");
           else
               return "Unknown-thread";
       }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to