ceki 2003/03/18 13:41:19 Modified: src/java/org/apache/log4j/spi LoggerEventListener.java LoggerRepository.java LocationInfo.java Filter.java HierarchyEventListener.java LoggerFactory.java Log: - Made code confirms to checkstyle 3.0. - Jalopy formatting. Revision Changes Path 1.3 +55 -13 jakarta-log4j/src/java/org/apache/log4j/spi/LoggerEventListener.java Index: LoggerEventListener.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/LoggerEventListener.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- LoggerEventListener.java 22 Nov 2002 11:03:29 -0000 1.2 +++ LoggerEventListener.java 18 Mar 2003 21:41:18 -0000 1.3 @@ -1,50 +1,92 @@ /* - * Copyright (C) The Apache Software Foundation. All rights reserved. + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ * - * This software is published under the terms of the Apache Software - * License version 1.1, a copy of which has been included with this - * distribution in the LICENSE.txt file. */ + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "log4j" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see <http://www.apache.org/>. + * + */ package org.apache.log4j.spi; -import org.apache.log4j.Logger; import org.apache.log4j.Appender; +import org.apache.log4j.Logger; + /** Interface used to listen for [EMAIL PROTECTED] Logger} related events such as add/remove appender or changing levels. Clients register an instance of the interface and the instance is called back when the various events occur. - + [EMAIL PROTECTED] LoggerRepository} provides methods for adding and removing LoggerEventListener instances. - + When implementing the methods of this interface, it is useful to remember that the Logger can access the repository using its getRepository() method. - + @author Ceki Gülcü @author Mark Womack @since 1.3 */ public interface LoggerEventListener { - /** Called when an appender is added to the logger. - + @param logger The logger to which the appender was added. @param appender The appender added to the logger. */ public void appenderAddedEvent(Logger logger, Appender appender); - + /** Called when an appender is removed from the logger. - + @param logger The logger from which the appender was removed. @param appender The appender removed from the logger. */ public void appenderRemovedEvent(Logger logger, Appender appender); /** Called when level changed on the logger. - + @param logger The logger that changed levels. */ public void levelChangedEvent(Logger logger); } 1.12 +60 -19 jakarta-log4j/src/java/org/apache/log4j/spi/LoggerRepository.java Index: LoggerRepository.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/LoggerRepository.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- LoggerRepository.java 22 Nov 2002 11:03:29 -0000 1.11 +++ LoggerRepository.java 18 Mar 2003 21:41:18 -0000 1.12 @@ -1,15 +1,59 @@ /* - * Copyright (C) The Apache Software Foundation. All rights reserved. + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ * - * This software is published under the terms of the Apache Software - * License version 1.1, a copy of which has been included with this - * distribution in the LICENSE.txt file. */ + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "log4j" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see <http://www.apache.org/>. + * + */ package org.apache.log4j.spi; import org.apache.log4j.*; + import java.util.Enumeration; + /** A <code>LoggerRepository</code> is used to create and retrieve <code>Loggers</code>. The relation between loggers in a repository @@ -24,14 +68,13 @@ @author Mark Womack @since 1.2 */ public interface LoggerRepository { - /** - Add a [EMAIL PROTECTED] LoggerRepositoryEventListener} to the repository. The - listener will be called when repository events occur. + Add a [EMAIL PROTECTED] LoggerRepositoryEventListener} to the repository. The + listener will be called when repository events occur. @since 1.3*/ public void addLoggerRepositoryEventListener( LoggerRepositoryEventListener listener); - + /** Remove a [EMAIL PROTECTED] LoggerRepositoryEventListener} from the repository. @since 1.3*/ @@ -39,11 +82,11 @@ LoggerRepositoryEventListener listener); /** - Add a [EMAIL PROTECTED] LoggerEventListener} to the repository. The listener + Add a [EMAIL PROTECTED] LoggerEventListener} to the repository. The listener will be called when repository events occur. @since 1.3*/ public void addLoggerEventListener(LoggerEventListener listener); - + /** Remove a [EMAIL PROTECTED] LoggerEventListener} from the repository. @since 1.3*/ @@ -94,33 +137,31 @@ /** Requests that a appender added event be sent to any registered [EMAIL PROTECTED] LoggerEventListener}. - @param logger The logger to which the appender was added. + @param logger The logger to which the appender was added. @param appender The appender added to the logger. @since 1.3*/ - public abstract void fireAddAppenderEvent(Logger logger, - Appender appender); + public abstract void fireAddAppenderEvent(Logger logger, Appender appender); /** Requests that a appender removed event be sent to any registered [EMAIL PROTECTED] LoggerEventListener}. - @param logger The logger from which the appender was removed. + @param logger The logger from which the appender was removed. @param appender The appender removed from the logger. @since 1.3*/ - public abstract void fireRemoveAppenderEvent(Logger logger, - Appender appender); + public abstract void fireRemoveAppenderEvent( + Logger logger, Appender appender); /** Requests that a level changed event be sent to any registered - [EMAIL PROTECTED] LoggerEventListener}. + [EMAIL PROTECTED] LoggerEventListener}. @param logger The logger which changed levels. @since 1.3*/ public abstract void fireLevelChangedEvent(Logger logger); /** Requests that a configuration changed event be sent to any registered - [EMAIL PROTECTED] LoggerRepositoryEventListener}. + [EMAIL PROTECTED] LoggerRepositoryEventListener}. @param logger The logger which changed levels. @since 1.3*/ public abstract void fireConfigurationChangedEvent(); - } 1.13 +240 -162 jakarta-log4j/src/java/org/apache/log4j/spi/LocationInfo.java Index: LocationInfo.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/LocationInfo.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- LocationInfo.java 24 Apr 2002 01:16:11 -0000 1.12 +++ LocationInfo.java 18 Mar 2003 21:41:18 -0000 1.13 @@ -1,18 +1,62 @@ /* - * Copyright (C) The Apache Software Foundation. All rights reserved. + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ * - * This software is published under the terms of the Apache Software - * License version 1.1, a copy of which has been included with this - * distribution in the LICENSE.txt file. */ + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "log4j" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see <http://www.apache.org/>. + * + */ -// Contributors: Mathias Rupprecht <[EMAIL PROTECTED]> +// Contributors: Mathias Rupprecht <[EMAIL PROTECTED]> package org.apache.log4j.spi; -import java.io.StringWriter; -import java.io.PrintWriter; -import org.apache.log4j.helpers.LogLog; import org.apache.log4j.Layout; +import org.apache.log4j.helpers.LogLog; + +import java.io.PrintWriter; +import java.io.StringWriter; + /** The internal representation of caller location information. @@ -20,53 +64,55 @@ @since 0.8.3 */ public class LocationInfo implements java.io.Serializable { + private static StringWriter sw = new StringWriter(); + private static PrintWriter pw = new PrintWriter(sw); + + /** + When location information is not available the constant + <code>NA</code> is returned. Current value of this string + constant is <b>?</b>. */ + public static final String NA = "?"; + static final long serialVersionUID = -1325822038990805636L; + + // Check if we are running in IBM's visual age. + static boolean inVisualAge = false; + + static { + try { + Class dummy = Class.forName("com.ibm.uvm.tools.DebugSupport"); + inVisualAge = true; + LogLog.debug("Detected IBM VisualAge environment."); + } catch (Throwable e) { + ; // nothing to do + } + } /** Caller's line number. */ transient String lineNumber; + /** Caller's file name. */ transient String fileName; + /** Caller's fully qualified class name. */ transient String className; + /** Caller's method name. */ transient String methodName; + /** All available caller information, in the format <code>fully.qualified.classname.of.caller.methodName(Filename.java:line)</code> */ public String fullInfo; - private static StringWriter sw = new StringWriter(); - private static PrintWriter pw = new PrintWriter(sw); - - /** - When location information is not available the constant - <code>NA</code> is returned. Current value of this string - constant is <b>?</b>. */ - public final static String NA = "?"; - - static final long serialVersionUID = -1325822038990805636L; - - - // Check if we are running in IBM's visual age. - static boolean inVisualAge = false; - static { - try { - Class dummy = Class.forName("com.ibm.uvm.tools.DebugSupport"); - inVisualAge = true; - LogLog.debug("Detected IBM VisualAge environment."); - } catch(Throwable e) { - // nothing to do - } - } - /** Instantiate location information based on a Throwable. We expect the Throwable <code>t</code>, to be in the format @@ -79,157 +125,189 @@ at org.apache.log4j.Category.callAppenders(Category.java:131) at org.apache.log4j.Category.log(Category.java:512) at callers.fully.qualified.className.methodName(FileName.java:74) - ... + ... </pre> <p>However, we can also deal with JIT compilers that "lose" the location information, especially between the parentheses. */ - public LocationInfo(Throwable t, String fqnOfCallingClass) { - if(t == null) - return; - - String s; - // Protect against multiple access to sw. - synchronized(sw) { - t.printStackTrace(pw); - s = sw.toString(); - sw.getBuffer().setLength(0); - } - //System.out.println("s is ["+s+"]."); - int ibegin, iend; + public LocationInfo(Throwable t, String fqnOfCallingClass) { + if (t == null) { + return; + } + + String s; + + // Protect against multiple access to sw. + synchronized (sw) { + t.printStackTrace(pw); + s = sw.toString(); + sw.getBuffer().setLength(0); + } + + //System.out.println("s is ["+s+"]."); + int ibegin; + + //System.out.println("s is ["+s+"]."); + int iend; + + // Given the current structure of the package, the line + // containing "org.apache.log4j.Category." should be printed just + // before the caller. + // This method of searching may not be fastest but it's safer + // than counting the stack depth which is not guaranteed to be + // constant across JVM implementations. + ibegin = s.lastIndexOf(fqnOfCallingClass); - // Given the current structure of the package, the line - // containing "org.apache.log4j.Category." should be printed just - // before the caller. - - // This method of searching may not be fastest but it's safer - // than counting the stack depth which is not guaranteed to be - // constant across JVM implementations. - ibegin = s.lastIndexOf(fqnOfCallingClass); - if(ibegin == -1) - return; - - - ibegin = s.indexOf(Layout.LINE_SEP, ibegin); - if(ibegin == -1) - return; - ibegin+= Layout.LINE_SEP_LEN; - - // determine end of line - iend = s.indexOf(Layout.LINE_SEP, ibegin); - if(iend == -1) - return; - - // VA has a different stack trace format which doesn't - // need to skip the inital 'at' - if(!inVisualAge) { - // back up to first blank character - ibegin = s.lastIndexOf("at ", iend); - if(ibegin == -1) - return; - // Add 3 to skip "at "; - ibegin += 3; + if (ibegin == -1) { + return; + } + + ibegin = s.indexOf(Layout.LINE_SEP, ibegin); + + if (ibegin == -1) { + return; + } + + ibegin += Layout.LINE_SEP_LEN; + + // determine end of line + iend = s.indexOf(Layout.LINE_SEP, ibegin); + + if (iend == -1) { + return; + } + + // VA has a different stack trace format which doesn't + // need to skip the inital 'at' + if (!inVisualAge) { + // back up to first blank character + ibegin = s.lastIndexOf("at ", iend); + + if (ibegin == -1) { + return; } - // everything between is the requested stack item - this.fullInfo = s.substring(ibegin, iend); + + // Add 3 to skip "at "; + ibegin += 3; } - /** - Return the fully qualified class name of the caller making the - logging request. - */ - public - String getClassName() { - if(fullInfo == null) return NA; - if(className == null) { - // Starting the search from '(' is safer because there is - // potentially a dot between the parentheses. - int iend = fullInfo.lastIndexOf('('); - if(iend == -1) - className = NA; - else { - iend =fullInfo.lastIndexOf('.', iend); - - // This is because a stack trace in VisualAge looks like: - - //java.lang.RuntimeException - // java.lang.Throwable() - // java.lang.Exception() - // java.lang.RuntimeException() - // void test.test.B.print() - // void test.test.A.printIndirect() - // void test.test.Run.main(java.lang.String []) - int ibegin = 0; - if (inVisualAge) { - ibegin = fullInfo.lastIndexOf(' ', iend)+1; - } - - if(iend == -1) - className = NA; - else - className = this.fullInfo.substring(ibegin, iend); - } + // everything between is the requested stack item + this.fullInfo = s.substring(ibegin, iend); + } + + /** + Return the fully qualified class name of the caller making the + logging request. + */ + public String getClassName() { + if (fullInfo == null) { + return NA; + } + + if (className == null) { + // Starting the search from '(' is safer because there is + // potentially a dot between the parentheses. + int iend = fullInfo.lastIndexOf('('); + + if (iend == -1) { + className = NA; + } else { + iend = fullInfo.lastIndexOf('.', iend); + + // This is because a stack trace in VisualAge looks like: + //java.lang.RuntimeException + // java.lang.Throwable() + // java.lang.Exception() + // java.lang.RuntimeException() + // void test.test.B.print() + // void test.test.A.printIndirect() + // void test.test.Run.main(java.lang.String []) + int ibegin = 0; + + if (inVisualAge) { + ibegin = fullInfo.lastIndexOf(' ', iend) + 1; + } + + if (iend == -1) { + className = NA; + } else { + className = this.fullInfo.substring(ibegin, iend); + } } - return className; } - /** - Return the file name of the caller. + return className; + } - <p>This information is not always available. - */ - public - String getFileName() { - if(fullInfo == null) return NA; - - if(fileName == null) { - int iend = fullInfo.lastIndexOf(':'); - if(iend == -1) - fileName = NA; - else { - int ibegin = fullInfo.lastIndexOf('(', iend - 1); - fileName = this.fullInfo.substring(ibegin + 1, iend); - } + /** + Return the file name of the caller. + + <p>This information is not always available. + */ + public String getFileName() { + if (fullInfo == null) { + return NA; + } + + if (fileName == null) { + int iend = fullInfo.lastIndexOf(':'); + + if (iend == -1) { + fileName = NA; + } else { + int ibegin = fullInfo.lastIndexOf('(', iend - 1); + fileName = this.fullInfo.substring(ibegin + 1, iend); } - return fileName; } - /** - Returns the line number of the caller. + return fileName; + } - <p>This information is not always available. - */ - public - String getLineNumber() { - if(fullInfo == null) return NA; - - if(lineNumber == null) { - int iend = fullInfo.lastIndexOf(')'); - int ibegin = fullInfo.lastIndexOf(':', iend -1); - if(ibegin == -1) - lineNumber = NA; - else - lineNumber = this.fullInfo.substring(ibegin + 1, iend); + /** + Returns the line number of the caller. + + <p>This information is not always available. + */ + public String getLineNumber() { + if (fullInfo == null) { + return NA; + } + + if (lineNumber == null) { + int iend = fullInfo.lastIndexOf(')'); + int ibegin = fullInfo.lastIndexOf(':', iend - 1); + + if (ibegin == -1) { + lineNumber = NA; + } else { + lineNumber = this.fullInfo.substring(ibegin + 1, iend); } - return lineNumber; } - /** - Returns the method name of the caller. - */ - public - String getMethodName() { - if(fullInfo == null) return NA; - if(methodName == null) { - int iend = fullInfo.lastIndexOf('('); - int ibegin = fullInfo.lastIndexOf('.', iend); - if(ibegin == -1) - methodName = NA; - else - methodName = this.fullInfo.substring(ibegin + 1, iend); + return lineNumber; + } + + /** + Returns the method name of the caller. + */ + public String getMethodName() { + if (fullInfo == null) { + return NA; + } + + if (methodName == null) { + int iend = fullInfo.lastIndexOf('('); + int ibegin = fullInfo.lastIndexOf('.', iend); + + if (ibegin == -1) { + methodName = NA; + } else { + methodName = this.fullInfo.substring(ibegin + 1, iend); } - return methodName; } + + return methodName; + } } 1.5 +73 -25 jakarta-log4j/src/java/org/apache/log4j/spi/Filter.java Index: Filter.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/Filter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Filter.java 5 Jul 2001 19:07:19 -0000 1.4 +++ Filter.java 18 Mar 2003 21:41:19 -0000 1.5 @@ -1,9 +1,51 @@ /* - * Copyright (C) The Apache Software Foundation. All rights reserved. + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ * - * This software is published under the terms of the Apache Software - * License version 1.1, a copy of which has been included with this - * distribution in the LICENSE.txt file. */ + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "log4j" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see <http://www.apache.org/>. + * + */ package org.apache.log4j.spi; @@ -29,7 +71,7 @@ <p>If the value [EMAIL PROTECTED] #DENY} is returned, then the log event is dropped immediately without consulting with the remaining - filters. + filters. <p>If the value [EMAIL PROTECTED] #NEUTRAL} is returned, then the next filter in the chain is consulted. If there are no more filters in the @@ -37,10 +79,10 @@ filters, the default behaviour is to log all logging events. <p>If the value [EMAIL PROTECTED] #ACCEPT} is returned, then the log - event is logged without consulting the remaining filters. + event is logged without consulting the remaining filters. <p>The philosophy of log4j filters is largely inspired from the - Linux ipchains. + Linux ipchains. <p>Note that filtering is only supported by the [EMAIL PROTECTED] org.apache.log4j.xml.DOMConfigurator DOMConfigurator}. The [EMAIL PROTECTED] @@ -50,17 +92,11 @@ @author Ceki Gülcü @since 0.9.0 */ public abstract class Filter implements OptionHandler { - - /** - Points to the next filter in the filter chain. - */ - public Filter next; - /** The log event must be dropped immediately without consulting with the remaining filters, if any, in the chain. */ - public static final int DENY = -1; - + public static final int DENY = -1; + /** This filter is neutral with respect to the log event. The remaining filters, if any, should be consulted for a final decision. @@ -70,20 +106,21 @@ /** The log event must be logged immediately without consulting with the remaining filters, if any, in the chain. */ - public static final int ACCEPT = 1; + public static final int ACCEPT = 1; + /** + Points to the next filter in the filter chain. + */ + private Filter next; /** Usually filters options become active when set. We provide a default do-nothing implementation for convenience. */ - public - void activateOptions() { + public void activateOptions() { } - - - /** + /** <p>If the decision is <code>DENY</code>, then the event will be dropped. If the decision is <code>NEUTRAL</code>, then the next filter, if any, will be invoked. If the decision is ACCEPT then @@ -92,8 +129,19 @@ @param event The LoggingEvent to decide upon. @param decision The decision of the filter. */ - abstract - public - int decide(LoggingEvent event); - + public abstract int decide(LoggingEvent event); + + /** + * Set the next filter pointer. + */ + public void setNext(Filter next) { + this.next = next; + } + + /** + * Return the pointer to the next filter; + */ + public Filter getNext() { + return next; + } } 1.5 +50 -15 jakarta-log4j/src/java/org/apache/log4j/spi/HierarchyEventListener.java Index: HierarchyEventListener.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/HierarchyEventListener.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- HierarchyEventListener.java 4 Sep 2001 18:44:47 -0000 1.4 +++ HierarchyEventListener.java 18 Mar 2003 21:41:19 -0000 1.5 @@ -1,34 +1,69 @@ /* - * Copyright (C) The Apache Software Foundation. All rights reserved. + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ * - * This software is published under the terms of the Apache Software - * License version 1.1, a copy of which has been included with this - * distribution in the LICENSE.txt file. */ + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "log4j" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see <http://www.apache.org/>. + * + */ package org.apache.log4j.spi; import org.apache.log4j.*; + /** Listen to events occuring within a [EMAIL PROTECTED] org.apache.log4j.Hierarchy Hierarchy}. @author Ceki Gülcü @since 1.2 - + */ public interface HierarchyEventListener { - - //public //void categoryCreationEvent(Category cat); + public void addAppenderEvent(Category cat, Appender appender); - - public - void addAppenderEvent(Category cat, Appender appender); - - public - void removeAppenderEvent(Category cat, Appender appender); - - + public void removeAppenderEvent(Category cat, Appender appender); } 1.3 +50 -10 jakarta-log4j/src/java/org/apache/log4j/spi/LoggerFactory.java Index: LoggerFactory.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/LoggerFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- LoggerFactory.java 4 Apr 2002 14:46:02 -0000 1.2 +++ LoggerFactory.java 18 Mar 2003 21:41:19 -0000 1.3 @@ -1,16 +1,59 @@ /* - * Copyright (C) The Apache Software Foundation. All rights reserved. + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ * - * This software is published under the terms of the Apache Software - * License version 1.1, a copy of which has been included with this - * distribution in the LICENSE.txt file. */ + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "log4j" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see <http://www.apache.org/>. + * + */ package org.apache.log4j.spi; import org.apache.log4j.Logger; + /** - + Implement this interface to create new instances of Logger or a sub-class of Logger. @@ -18,11 +61,8 @@ @author Ceki Gülcü @since version 0.8.5 - + */ public interface LoggerFactory { - - public - Logger makeNewLoggerInstance(String name); - + public Logger makeNewLoggerInstance(String name); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]