cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject cvs commit: cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup AbstractLogger.java ConsoleLogger.java ServletLogger.java
Date Sat, 15 May 2004 23:07:50 GMT
pier        2004/05/15 16:07:50

  Modified:    src/kernel/org/apache/cocoon/kernel DeployedWirings.java
               src/kernel/org/apache/cocoon/kernel/logging Logger.java
               src/kernel/org/apache/cocoon/kernel/startup
                        AbstractLogger.java ConsoleLogger.java
                        ServletLogger.java
  Log:
  Better logging
  
  Revision  Changes    Path
  1.11      +2 -2      cocoon-2.2/src/kernel/org/apache/cocoon/kernel/DeployedWirings.java
  
  Index: DeployedWirings.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/DeployedWirings.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DeployedWirings.java	7 May 2004 21:00:30 -0000	1.10
  +++ DeployedWirings.java	15 May 2004 23:07:50 -0000	1.11
  @@ -80,7 +80,7 @@
       throws DeploymentException {
           this.instance = i;
           this.deployer = d;
  -        this.logger = l;
  +        this.logger = l.subLogger(i.name());
   
           /* Retrieve all we need from our instance regarding composers */
           LoadedBlock block = (LoadedBlock) i.block();
  
  
  
  1.2       +10 -1     cocoon-2.2/src/kernel/org/apache/cocoon/kernel/logging/Logger.java
  
  Index: Logger.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/logging/Logger.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Logger.java	6 May 2004 20:09:33 -0000	1.1
  +++ Logger.java	15 May 2004 23:07:50 -0000	1.2
  @@ -117,4 +117,13 @@
        */
       public void fatal(String message, Throwable throwable) {
       }
  +    
  +    /**
  +     * <p>Return a sub-{@link Logger} of this {@link Logger}.</p>
  +     * 
  +     * @return a {@link Logger} instance associated with a specific name.
  +     */
  +    public Logger subLogger(String name) {
  +        return(this);
  +    }
   }
  
  
  
  1.9       +23 -12    cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/AbstractLogger.java
  
  Index: AbstractLogger.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/AbstractLogger.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractLogger.java	6 May 2004 20:09:33 -0000	1.8
  +++ AbstractLogger.java	15 May 2004 23:07:50 -0000	1.9
  @@ -51,17 +51,20 @@
       /* ====================================================================== */
   
       /** <p>The logging level.</p> */
  -    private int level = DEBUG;
  +    protected int level = DEBUG;
   
       /** <p>The name of this logger.</p> */
  -    private String name = null;
  +    protected String name = null;
       
  -    /** <p>The timestamp formatter (if any).</p> */
  -    private SimpleDateFormat time = null;
  -
       /** <p>Whether we should produce exception stack traces or not.</p> */
  -    private boolean trace = true;
  +    protected boolean trace = true;
  +    
  +    /** <p>Whether we should produce a timestamp or not.</p> */
  +    protected boolean time = true;
       
  +    /** <p>The timestamp formatter (if any).</p> */
  +    private SimpleDateFormat format = null;
  +
       /* ====================================================================== */
           
       /**
  @@ -81,11 +84,12 @@
           else if (level > FATAL) this.level = FATAL;
           else this.level = level;
   
  -        /* Produce a timestamp? */
  -        if (time) this.time = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
  -        
  -        /* Trace exceptions? */
  +        /* Produce a timestamp? Trace exceptions? */
           this.trace = trace;
  +        this.time = time;
  +        if (this.time) {
  +            this.format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
  +        }
       }
       
       /* ====================================================================== */
  @@ -210,7 +214,7 @@
           StringBuffer buffer = new StringBuffer(64);
           
           /* If we got a time formatter, append the time */
  -        if (this.time != null) buffer.append(this.time.format(new Date()));
  +        if (this.format != null) buffer.append(this.format.format(new Date()));
           
           /* Dump out the log level */
           if (buffer.length() > 0) buffer.append(" ");
  @@ -330,4 +334,11 @@
           if (buffer != null) this.output(buffer.toString());
           return(new StringBuffer(200));
       }
  +
  +    /**
  +     * <p>Return a sub-{@link Logger} of this {@link Logger}.</p>
  +     * 
  +     * @return a {@link Logger} instance associated with a specific name.
  +     */
  +    public abstract Logger subLogger(String name);
   }
  
  
  
  1.6       +16 -1     cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/ConsoleLogger.java
  
  Index: ConsoleLogger.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/ConsoleLogger.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ConsoleLogger.java	9 May 2004 14:52:56 -0000	1.5
  +++ ConsoleLogger.java	15 May 2004 23:07:50 -0000	1.6
  @@ -139,4 +139,19 @@
       public void output(String line) {
           this.out.println(line);
       }
  +
  +    /**
  +     * <p>Return a sub-{@link Logger} of this {@link Logger}.</p>
  +     * 
  +     * @return a {@link Logger} instance associated with a specific name.
  +     */
  +    public Logger subLogger(String name) {
  +        if (name == null) {
  +            this.debug("Requested child logger without name (returning self)");
  +            return(this);
  +        }
  +
  +        name = (this.name == null ? name : this.name + "." + name);
  +        return new ConsoleLogger(name, level, time, trace, out);
  +    }
   }
  
  
  
  1.3       +32 -5     cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/ServletLogger.java
  
  Index: ServletLogger.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/startup/ServletLogger.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServletLogger.java	9 May 2004 14:52:56 -0000	1.2
  +++ ServletLogger.java	15 May 2004 23:07:50 -0000	1.3
  @@ -38,7 +38,7 @@
        * @param context the {@link ServletContext} to log to.
        */
       public ServletLogger(ServletContext context) {
  -        this(DEBUG, true, context);
  +        this(null, DEBUG, true, context);
       }
       
       /**
  @@ -50,10 +50,22 @@
        * @param context the {@link ServletContext} to log to.
        */
       public ServletLogger(int level, boolean trace, ServletContext context) {
  -        super(null, level, false, trace);
  +        this(null, level, trace, context);
  +    }
   
  -        if (context == null) throw new NullPointerException("Null context");
  -        this.context = context;
  +    /**
  +     * <p>Create a new {@link ServletLogger} associated with a specific
  +     * {@link ServletContext}.</p>
  +     *
  +     * @param nam the name of this instance.
  +     * @param lvl the level of output.
  +     * @param trc if <b>true</b> exception stack traces will be produced.
  +     * @param ctx the {@link ServletContext} to log to.
  +     */
  +    public ServletLogger(String nam, int lvl, boolean trc, ServletContext ctx) {
  +        super(nam, lvl, false, trc);
  +        if (ctx == null) throw new NullPointerException("Null context");
  +        this.context = ctx;
       }
       
       /* ====================================================================== */
  @@ -65,5 +77,20 @@
        */
       public void output(String line) {
           this.context.log(line);
  +    }
  +
  +    /**
  +     * <p>Return a sub-{@link Logger} of this {@link Logger}.</p>
  +     * 
  +     * @return a {@link Logger} instance associated with a specific name.
  +     */
  +    public Logger subLogger(String name) {
  +        if (name == null) {
  +            this.debug("Requested child logger without name (returning self)");
  +            return(this);
  +        }
  +
  +        name = (this.name == null ? name : this.name + "." + name);
  +        return new ServletLogger(name, level, trace, context);
       }
   }
  
  
  

Mime
View raw message