cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon cocoon.properties Defaults.java Engine.java
Date Fri, 17 Mar 2000 16:47:00 GMT
stefano     00/03/17 08:46:59

  Modified:    src/org/apache/cocoon cocoon.properties Defaults.java
                        Engine.java
  Log:
  added logger (let's not add too many log hooks since this slows down the thing when turned
on, still you can safely remove all the logging at compile time for maximum performance)
  
  Revision  Changes    Path
  1.18      +9 -1      xml-cocoon/src/org/apache/cocoon/cocoon.properties
  
  Index: cocoon.properties
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/cocoon.properties,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- cocoon.properties	2000/02/24 23:05:28	1.17
  +++ cocoon.properties	2000/03/17 16:46:58	1.18
  @@ -18,8 +18,16 @@
   # or return the HTTP error code to the web server and let it handle it.
   handle.errors.internally = true
   
  +# Indicates the log severity level
  +#log.level = emergency
  +#log.level = critical
  +#log.level = error
  +#log.level = warning
  +#log.level = info
  +log.level = debug
   
   
  +
   ##########################################
   # XML Parsers                            #
   ##########################################
  @@ -219,6 +227,6 @@
   browser.1 = opera=Opera
   browser.2 = lynx=Lynx
   browser.3 = java=Java
  -browser.4 = wap=Nokia-WAP-Toolkit
  +browser.4 = wap=Nokia
   browser.5 = wap=UP
   browser.6 = netscape=Mozilla
  
  
  
  1.11      +6 -3      xml-cocoon/src/org/apache/cocoon/Defaults.java
  
  Index: Defaults.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Defaults.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Defaults.java	2000/02/14 00:59:17	1.10
  +++ Defaults.java	2000/03/17 16:46:58	1.11
  @@ -1,4 +1,4 @@
  -/*-- $Id: Defaults.java,v 1.10 2000/02/14 00:59:17 stefano Exp $ --
  +/*-- $Id: Defaults.java,v 1.11 2000/03/17 16:46:58 stefano Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -54,7 +54,7 @@
    * The Cocoon strings.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.10 $ $Date: 2000/02/14 00:59:17 $
  + * @version $Revision: 1.11 $ $Date: 2000/03/17 16:46:58 $
    */
   
   public interface Defaults {
  @@ -72,6 +72,7 @@
       public static final String STATUS_URL = "selfservlet.uri";
       public static final String STATUS_URL_DEFAULT = "/Cocoon.xml";
       public static final String ERROR_INTERNALLY = "handle.errors.internally";
  +    public static final String LOG_LEVEL = "log.level";
   
       public static final String PARSER_PROP = "parser";
       public static final String PARSER_DEFAULT = "org.apache.cocoon.parser.XercesParser";
  @@ -96,5 +97,7 @@
   
       public static final int LOOPS = 10;
   
  -    public static final boolean VERBOSE = true;
  +    public static final boolean VERBOSE = @verbose@;
  +    public static final boolean LOG = @log@;
  +
   }
  
  
  
  1.20      +21 -2     xml-cocoon/src/org/apache/cocoon/Engine.java
  
  Index: Engine.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Engine.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Engine.java	2000/02/23 00:50:47	1.19
  +++ Engine.java	2000/03/17 16:46:59	1.20
  @@ -1,4 +1,4 @@
  -/*-- $Id: Engine.java,v 1.19 2000/02/23 00:50:47 stefano Exp $ --
  +/*-- $Id: Engine.java,v 1.20 2000/03/17 16:46:59 stefano Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -59,6 +59,7 @@
   import org.apache.cocoon.cache.*;
   import org.apache.cocoon.store.*;
   import org.apache.cocoon.parser.*;
  +import org.apache.cocoon.logger.*;
   import org.apache.cocoon.transformer.*;
   import org.apache.cocoon.producer.*;
   import org.apache.cocoon.formatter.*;
  @@ -72,7 +73,7 @@
    * This class implements the engine that does all the document processing.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.19 $ $Date: 2000/02/23 00:50:47 $
  + * @version $Revision: 1.20 $ $Date: 2000/03/17 16:46:59 $
    */
   
   public class Engine implements Defaults {
  @@ -94,6 +95,7 @@
       Transformer transformer;
       Cache cache;
       Store store;
  +    Logger logger;
   
       ServletContext servletContext;
   
  @@ -117,6 +119,10 @@
   
               // register the context
               manager.setRole("context", context);
  +
  +            // use the context for the logger
  +            logger = new ServletLogger(this.servletContext, (String) configurations.get(LOG_LEVEL));
  +            manager.setRole("logger", logger);
           }
   
           // Create the parser and register it
  @@ -216,6 +222,8 @@
        */
       public void handle(HttpServletRequest request, HttpServletResponse response) throws
Exception {
   
  +        if (LOG) logger.log(this, "Starting request", Logger.INFO);
  +
           // if verbose mode is on, take a time snapshot for later evaluation
           long time = 0;
           if (VERBOSE) time = System.currentTimeMillis();
  @@ -253,6 +261,8 @@
           // disabled, we need to process it
           if (page == null) {
   
  +            if (LOG) logger.log(this, "Creating page", Logger.DEBUG);
  +
               // continue until the page is done.
               for (int i = 0; i < LOOPS; i++) {
                   // catch if any OutOfMemoryError is thrown
  @@ -269,6 +279,8 @@
                       // pass the produced stream to the parser
                       Document document = producer.getDocument(request);
   
  +                    if (LOG) logger.log(this, "Document produced", Logger.DEBUG);
  +
                       // pass needed parameters to the processor pipeline
                       Hashtable environment = new Hashtable();
                       environment.put("path", producer.getPath(request));
  @@ -282,6 +294,7 @@
                           if (processor == null) break;
                           document = processor.process(document, environment);
                           page.setChangeable(processor);
  +                        if (LOG) logger.log(this, "Document processed", Logger.DEBUG);
                       }
   
                       // get the right formatter for the page
  @@ -295,6 +308,8 @@
                       StringWriter writer = new StringWriter();
                       formatter.format(document, writer, environment);
   
  +                    if (LOG) logger.log(this, "Document formatted", Logger.DEBUG);
  +
                       // fill the page bean with content
                       page.setContent(writer.toString());
                       page.setContentType(formatter.getMIMEType());
  @@ -302,6 +317,7 @@
                       // page is done without memory errors so exit the loop
                       break;
                   } catch (OutOfMemoryError e) {
  +                    if (LOG) logger.log(this, "Triggered OutOfMemory", Logger.WARNING);
                       // force the cache to free some of its content.
                       cache.flush();
                       // reset the page to signal the error
  @@ -311,6 +327,7 @@
           }
   
           if (page == null) {
  +            if (LOG) logger.log(this, "System is out of memory", Logger.EMERGENCY);
               throw new Exception("FATAL ERROR: the system ran out of memory when"
                   + " processing the request. Increase your JVM memory.");
           }
  @@ -344,6 +361,8 @@
               // send all content so that client doesn't wait while caching.
               out.flush();
           }
  +
  +        if (LOG) logger.log(this, "response sent to client", Logger.WARNING);
   
           // cache the created page.
           cache.setPage(page, request);
  
  
  

Mime
View raw message