commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skitch...@apache.org
Subject svn commit: r177949 [2/2] - in /jakarta/commons/proper/logging/branches/simon-1.1: ./ src/ src/conf/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/commons/ src/java/org/apache/commons/logging/ src/java/org/apache/commons/logging/impl/ src/media/ src/test/ src/test/org/ src/test/org/apache/ src/test/org/apache/commons/ src/test/org/apache/commons/logging/ src/test/org/apache/commons/logging/jdk14/ src/test/org/apache/commons/logging/log4j/ src/test/org/apache/commons/logging/simple/ target/
Date Mon, 23 May 2005 10:46:08 GMT
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpLogger.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpLogger.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpLogger.java
(added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpLogger.java
Mon May 23 03:46:05 2005
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.logging.impl;
+
+
+import java.io.Serializable;
+import org.apache.commons.logging.Log;
+
+
+/**
+ * <p>Trivial implementation of Log that throws away all messages.  No
+ * configurable system properties are supported.</p>
+ *
+ * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
+ * @author Rod Waldhoff
+ * @version $Id$
+ */
+public class NoOpLogger implements Log, Serializable {
+
+    /** Convenience constructor */
+    public NoOpLogger() { }
+    /** Base constructor */
+    public NoOpLogger(String name) { }
+    /** Do nothing */
+    public void trace(Object message) { }
+    /** Do nothing */
+    public void trace(Object message, Throwable t) { }
+    /** Do nothing */
+    public void debug(Object message) { }
+    /** Do nothing */
+    public void debug(Object message, Throwable t) { }
+    /** Do nothing */
+    public void info(Object message) { }
+    /** Do nothing */
+    public void info(Object message, Throwable t) { }
+    /** Do nothing */
+    public void warn(Object message) { }
+    /** Do nothing */
+    public void warn(Object message, Throwable t) { }
+    /** Do nothing */
+    public void error(Object message) { }
+    /** Do nothing */
+    public void error(Object message, Throwable t) { }
+    /** Do nothing */
+    public void fatal(Object message) { }
+    /** Do nothing */
+    public void fatal(Object message, Throwable t) { }
+
+    /**
+     * Debug is never enabled.
+     *
+     * @return false
+     */
+    public final boolean isDebugEnabled() { return false; }
+
+    /**
+     * Error is never enabled.
+     *
+     * @return false
+     */
+    public final boolean isErrorEnabled() { return false; }
+
+    /**
+     * Fatal is never enabled.
+     *
+     * @return false
+     */
+    public final boolean isFatalEnabled() { return false; }
+
+    /**
+     * Info is never enabled.
+     *
+     * @return false
+     */
+    public final boolean isInfoEnabled() { return false; }
+
+    /**
+     * Trace is never enabled.
+     *
+     * @return false
+     */
+    public final boolean isTraceEnabled() { return false; }
+
+    /**
+     * Warn is never enabled.
+     *
+     * @return false
+     */
+    public final boolean isWarnEnabled() { return false; }
+
+}

Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpLogger.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleFactory.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleFactory.java
(added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleFactory.java
Mon May 23 03:46:05 2005
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging.impl;
+
+
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.Factory;
+
+/**
+ * Concrete subclass of {@link Factory} specific to SimpleLogger.
+ */
+public final class SimpleFactory extends Factory {
+
+    public SimpleFactory() {
+        super();
+        init();
+    }
+
+    // ------------------------------------------------------- Attributes
+
+    // Previously returned instances, to avoid creation of proxies
+    private Hashtable instances = new Hashtable();
+
+    /** All system properties used by <code>SimpleLog</code> start with this
*/
+    private static final String systemPrefix =
+        "org.apache.commons.logging.SimpleLogger.";
+
+    /** The default format to use when formating dates */
+    private static final String DEFAULT_DATE_TIME_FORMAT =
+        "yyyy/MM/dd HH:mm:ss:SSS zzz";
+
+    /** Properties loaded from SimpleLogger.properties */
+    private final Properties simpleLogProps = new Properties();
+
+    /** Include the instance name in the log message? */
+    boolean showLogName = false;
+
+    /** Include the short name ( last component ) of the logger in the log
+     *  message. Defaults to true - otherwise we'll be lost in a flood of
+     *  messages without knowing who sends them.
+     */
+    boolean showShortName = true;
+
+    /** Include the current time in the log message */
+    boolean showDateTime = false;
+
+    /** The date and time format to use in the log message */
+    String dateTimeFormat = DEFAULT_DATE_TIME_FORMAT;
+
+    /** Used to format times */
+    DateFormat dateFormatter = null;
+
+    
+    private String getStringProperty(String name) {
+        String prop = null;
+    try {
+        prop = System.getProperty(name);
+    } catch (SecurityException e) {
+        ; // Ignore
+    }
+        return (prop == null) ? simpleLogProps.getProperty(name) : prop;
+    }
+
+    private String getStringProperty(String name, String dephault) {
+        String prop = getStringProperty(name);
+        return (prop == null) ? dephault : prop;
+    }
+
+    private boolean getBooleanProperty(String name, boolean dephault) {
+        String prop = getStringProperty(name);
+        return (prop == null) ? dephault : "true".equalsIgnoreCase(prop);
+    }
+
+    private void init() {
+        // Initialize class attributes.
+        // Load properties file, if found.
+        // Override with system properties.
+        // Add props from the resource SimpleLogger.properties
+        InputStream in = this.getClass().getClassLoader().getResourceAsStream(
+                "SimpleLogger.properties");
+        if(null != in) {
+            try {
+                simpleLogProps.load(in);
+                in.close();
+            } catch(java.io.IOException e) {
+                // ignored
+            }
+        }
+
+        showLogName = getBooleanProperty( systemPrefix + "showlogname", showLogName);
+        showShortName = getBooleanProperty( systemPrefix + "showShortLogname", showShortName);
+        showDateTime = getBooleanProperty( systemPrefix + "showdatetime", showDateTime);
+
+        if(showDateTime) {
+            dateTimeFormat = getStringProperty(systemPrefix + "dateTimeFormat",
+                                               dateTimeFormat);
+            try {
+                dateFormatter = new SimpleDateFormat(dateTimeFormat);
+            } catch(IllegalArgumentException e) {
+                // If the format pattern is invalid - use the default format
+                dateTimeFormat = DEFAULT_DATE_TIME_FORMAT;
+                dateFormatter = new SimpleDateFormat(dateTimeFormat);
+            }
+        }
+    }
+
+
+    
+    // --------------------------------------------------------- Public Methods
+
+    /**
+     * Given a category name, check the system properties to see whether
+     * a specific value has been assigned for that level.
+     */
+    private int getLevel(String name) {
+        int level = SimpleLogger.LOG_LEVEL_INFO;
+
+        // Set log level from properties
+        String lvl = getStringProperty(systemPrefix + "log." + name);
+        int i = String.valueOf(name).lastIndexOf(".");
+        while(null == lvl && i > -1) {
+            name = name.substring(0,i);
+            lvl = getStringProperty(systemPrefix + "log." + name);
+            i = String.valueOf(name).lastIndexOf(".");
+        }
+
+        if(null == lvl) {
+            lvl =  getStringProperty(systemPrefix + "defaultlog");
+        }
+
+        if("all".equalsIgnoreCase(lvl)) {
+            level = SimpleLogger.LOG_LEVEL_ALL;
+        } else if("trace".equalsIgnoreCase(lvl)) {
+            level = SimpleLogger.LOG_LEVEL_TRACE;
+        } else if("debug".equalsIgnoreCase(lvl)) {
+            level = SimpleLogger.LOG_LEVEL_DEBUG;
+        } else if("info".equalsIgnoreCase(lvl)) {
+            level = SimpleLogger.LOG_LEVEL_INFO;
+        } else if("warn".equalsIgnoreCase(lvl)) {
+            level = SimpleLogger.LOG_LEVEL_WARN;
+        } else if("error".equalsIgnoreCase(lvl)) {
+            level = SimpleLogger.LOG_LEVEL_ERROR;
+        } else if("fatal".equalsIgnoreCase(lvl)) {
+            level = SimpleLogger.LOG_LEVEL_FATAL;
+        } else if("off".equalsIgnoreCase(lvl)) {
+            level = SimpleLogger.LOG_LEVEL_OFF;
+        }
+        
+        return level;
+    }
+    
+    /**
+     * Return a logger associated with the specified category name.
+     */
+    public Log getLog(String name) {
+        Log instance = (Log) instances.get(name);
+        if (instance != null)
+            return instance;
+
+        int level = getLevel(name);
+
+        instance = new SimpleLogger(this, name, level);
+        instances.put(name, instance);
+        return instance;
+    }
+
+
+    /**
+     * Release any internal references to previously created {@link Log}
+     * instances returned by this factory.  This is useful in environments
+     * like servlet containers, which implement application reloading by
+     * throwing away a ClassLoader.  Dangling references to objects in that
+     * class loader would prevent garbage collection.
+     */
+    public void release(ClassLoader cl) {
+        instances.clear();
+    }
+    
+    public void releaseAll() {
+        instances.clear();
+    }
+}
\ No newline at end of file

Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleLogger.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleLogger.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleLogger.java
(added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleLogger.java
Mon May 23 03:46:05 2005
@@ -0,0 +1,421 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.logging.impl;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * <p>Simple implementation of Log that sends all enabled log messages,
+ * for all defined loggers, to System.err.  The following system properties
+ * are supported to configure the behavior of this logger:</p>
+ * <ul>
+ * <li><code>org.apache.commons.logging.SimpleLogger.defaultlog</code>
-
+ *     Default logging detail level for all instances of SimpleLogger.
+ *     Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
+ *     If not specified, defaults to "info". </li>
+ * <li><code>org.apache.commons.logging.SimpleLogger.log.xxxxx</code> -
+ *     Logging detail level for a SimpleLog instance named "xxxxx".
+ *     Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
+ *     If not specified, the default logging detail level is used.</li>
+ * <li><code>org.apache.commons.logging.SimpleLogger.showlogname</code>
-
+ *     Set to <code>true</code> if you want the Log instance name to be
+ *     included in output messages. Defaults to <code>false</code>.</li>
+ * <li><code>org.apache.commons.logging.SimpleLogger.showShortLogname</code>
-
+ *     Set to <code>true</code> if you want the last component of the name to
be
+ *     included in output messages. Defaults to <code>true</code>.</li>
+ * <li><code>org.apache.commons.logging.SimpleLogger.showdatetime</code>
-
+ *     Set to <code>true</code> if you want the current date and time
+ *     to be included in output messages. Default is <code>false</code>.</li>
+ * <li><code>org.apache.commons.logging.SimpleLogger.dateTimeFormat</code>
-
+ *     The date and time format to be used in the output messages.
+ *     The pattern describing the date and time format is the same that is
+ *     used in <code>java.text.SimpleDateFormat</code>. If the format is not
+ *     specified or is invalid, the default format is used.
+ *     The default format is <code>yyyy/MM/dd HH:mm:ss:SSS zzz</code>.</li>
+ * </ul>
+ *
+ * <p>In addition to looking for system properties with the names specified
+ * above, this implementation also checks for a class loader resource named
+ * <code>"SimpleLogger.properties"</code>, and includes any matching definitions
+ * from this resource (if it exists).</p>
+ *
+ * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
+ * @author Rod Waldhoff
+ * @author Robert Burrell Donkin
+ *
+ * @version $Id$
+ */
+public class SimpleLogger implements Log, Serializable {
+
+
+    // ---------------------------------------------------- Log Level Constants
+
+
+    /** "Trace" level logging. */
+    public static final int LOG_LEVEL_TRACE  = 1;
+    /** "Debug" level logging. */
+    public static final int LOG_LEVEL_DEBUG  = 2;
+    /** "Info" level logging. */
+    public static final int LOG_LEVEL_INFO   = 3;
+    /** "Warn" level logging. */
+    public static final int LOG_LEVEL_WARN   = 4;
+    /** "Error" level logging. */
+    public static final int LOG_LEVEL_ERROR  = 5;
+    /** "Fatal" level logging. */
+    public static final int LOG_LEVEL_FATAL  = 6;
+
+    /** Enable all logging levels */
+    public static final int LOG_LEVEL_ALL    = (LOG_LEVEL_TRACE - 1);
+
+    /** Enable no logging levels */
+    public static final int LOG_LEVEL_OFF    = (LOG_LEVEL_FATAL + 1);
+
+    // ------------------------------------------------------------- Attributes
+
+    protected SimpleFactory factory;
+    
+    /** The name of this simple log instance */
+    protected String logName = null;
+    
+    /** The current log level */
+    protected int currentLogLevel;
+    
+    /** The short name of this simple log instance */
+    private String shortLogName = null;
+
+
+    // ------------------------------------------------------------ Constructor
+
+    /**
+     * Construct a simple log with given name.
+     *
+     * @param name log name
+     */
+    public SimpleLogger(SimpleFactory factory, String name, int level) {
+        this.factory = factory;
+        this.logName = name;
+        this.currentLogLevel = level;
+        
+        shortLogName = logName.substring(logName.lastIndexOf(".") + 1);
+        shortLogName = shortLogName.substring(shortLogName.lastIndexOf("/") + 1);
+    }
+
+    // -------------------------------------------------------- Logging Methods
+
+
+    /**
+     * <p> Do the actual logging.
+     * This method assembles the message
+     * and then calls <code>write()</code> to cause it to be written.</p>
+     *
+     * @param type One of the LOG_LEVEL_XXX constants defining the log level
+     * @param message The message itself (typically a String)
+     * @param t The exception whose stack trace should be logged
+     */
+    protected void log(int type, Object message, Throwable t) {
+        // Use a string buffer for better performance
+        StringBuffer buf = new StringBuffer();
+
+        // Append date-time if so configured
+        if(factory.showDateTime) {
+            buf.append(factory.dateFormatter.format(new Date()));
+            buf.append(" ");
+        }
+
+        // Append a readable representation of the log level
+        switch(type) {
+            case SimpleLogger.LOG_LEVEL_TRACE: buf.append("[TRACE] "); break;
+            case SimpleLogger.LOG_LEVEL_DEBUG: buf.append("[DEBUG] "); break;
+            case SimpleLogger.LOG_LEVEL_INFO:  buf.append("[INFO] ");  break;
+            case SimpleLogger.LOG_LEVEL_WARN:  buf.append("[WARN] ");  break;
+            case SimpleLogger.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break;
+            case SimpleLogger.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break;
+        }
+
+        // Append the name of the log instance if so configured
+ 	if( factory.showShortName) {
+            buf.append(String.valueOf(shortLogName)).append(" - ");
+        } else if(factory.showLogName) {
+            buf.append(String.valueOf(logName)).append(" - ");
+        }
+
+        // Append the message
+        buf.append(String.valueOf(message));
+
+        // Append stack trace if not null
+        if(t != null) {
+            buf.append(" <");
+            buf.append(t.toString());
+            buf.append(">");
+
+            java.io.StringWriter sw= new java.io.StringWriter(1024);
+            java.io.PrintWriter pw= new java.io.PrintWriter(sw);
+            t.printStackTrace(pw);
+            pw.close();
+            buf.append(sw.toString());
+        }
+
+        // Print to the appropriate destination
+        write(buf);
+
+    }
+
+
+    /**
+     * <p>Write the content of the message accumulated in the specified
+     * <code>StringBuffer</code> to the appropriate output destination.  The
+     * default implementation writes to <code>System.err</code>.</p>
+     *
+     * @param buffer A <code>StringBuffer</code> containing the accumulated
+     *  text to be logged
+     */
+    protected void write(StringBuffer buffer) {
+
+        System.err.println(buffer.toString());
+
+    }
+
+
+    /**
+     * Is the given log level currently enabled?
+     *
+     * @param logLevel is this level enabled?
+     */
+    protected boolean isLevelEnabled(int logLevel) {
+        // log level are numerically ordered so can use simple numeric
+        // comparison
+        return (logLevel >= currentLogLevel);
+    }
+
+
+    // -------------------------------------------------------- Log Implementation
+
+
+    /**
+     * <p> Log a message with debug log level.</p>
+     */
+    public final void debug(Object message) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_DEBUG)) {
+            log(SimpleLogger.LOG_LEVEL_DEBUG, message, null);
+        }
+    }
+
+
+    /**
+     * <p> Log an error with debug log level.</p>
+     */
+    public final void debug(Object message, Throwable t) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_DEBUG)) {
+            log(SimpleLogger.LOG_LEVEL_DEBUG, message, t);
+        }
+    }
+
+
+    /**
+     * <p> Log a message with trace log level.</p>
+     */
+    public final void trace(Object message) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_TRACE)) {
+            log(SimpleLogger.LOG_LEVEL_TRACE, message, null);
+        }
+    }
+
+
+    /**
+     * <p> Log an error with trace log level.</p>
+     */
+    public final void trace(Object message, Throwable t) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_TRACE)) {
+            log(SimpleLogger.LOG_LEVEL_TRACE, message, t);
+        }
+    }
+
+
+    /**
+     * <p> Log a message with info log level.</p>
+     */
+    public final void info(Object message) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_INFO)) {
+            log(SimpleLogger.LOG_LEVEL_INFO,message,null);
+        }
+    }
+
+
+    /**
+     * <p> Log an error with info log level.</p>
+     */
+    public final void info(Object message, Throwable t) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_INFO)) {
+            log(SimpleLogger.LOG_LEVEL_INFO, message, t);
+        }
+    }
+
+
+    /**
+     * <p> Log a message with warn log level.</p>
+     */
+    public final void warn(Object message) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_WARN)) {
+            log(SimpleLogger.LOG_LEVEL_WARN, message, null);
+        }
+    }
+
+
+    /**
+     * <p> Log an error with warn log level.</p>
+     */
+    public final void warn(Object message, Throwable t) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_WARN)) {
+            log(SimpleLogger.LOG_LEVEL_WARN, message, t);
+        }
+    }
+
+
+    /**
+     * <p> Log a message with error log level.</p>
+     */
+    public final void error(Object message) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_ERROR)) {
+            log(SimpleLogger.LOG_LEVEL_ERROR, message, null);
+        }
+    }
+
+
+    /**
+     * <p> Log an error with error log level.</p>
+     */
+    public final void error(Object message, Throwable t) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_ERROR)) {
+            log(SimpleLogger.LOG_LEVEL_ERROR, message, t);
+        }
+    }
+
+
+    /**
+     * <p> Log a message with fatal log level.</p>
+     */
+    public final void fatal(Object message) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_FATAL)) {
+            log(SimpleLogger.LOG_LEVEL_FATAL, message, null);
+        }
+    }
+
+
+    /**
+     * <p> Log an error with fatal log level.</p>
+     */
+    public final void fatal(Object message, Throwable t) {
+
+        if (isLevelEnabled(SimpleLogger.LOG_LEVEL_FATAL)) {
+            log(SimpleLogger.LOG_LEVEL_FATAL, message, t);
+        }
+    }
+
+
+    /**
+     * <p> Are debug messages currently enabled? </p>
+     *
+     * <p> This allows expensive operations such as <code>String</code>
+     * concatenation to be avoided when the message will be ignored by the
+     * logger. </p>
+     */
+    public final boolean isDebugEnabled() {
+
+        return isLevelEnabled(SimpleLogger.LOG_LEVEL_DEBUG);
+    }
+
+
+    /**
+     * <p> Are error messages currently enabled? </p>
+     *
+     * <p> This allows expensive operations such as <code>String</code>
+     * concatenation to be avoided when the message will be ignored by the
+     * logger. </p>
+     */
+    public final boolean isErrorEnabled() {
+
+        return isLevelEnabled(SimpleLogger.LOG_LEVEL_ERROR);
+    }
+
+
+    /**
+     * <p> Are fatal messages currently enabled? </p>
+     *
+     * <p> This allows expensive operations such as <code>String</code>
+     * concatenation to be avoided when the message will be ignored by the
+     * logger. </p>
+     */
+    public final boolean isFatalEnabled() {
+
+        return isLevelEnabled(SimpleLogger.LOG_LEVEL_FATAL);
+    }
+
+
+    /**
+     * <p> Are info messages currently enabled? </p>
+     *
+     * <p> This allows expensive operations such as <code>String</code>
+     * concatenation to be avoided when the message will be ignored by the
+     * logger. </p>
+     */
+    public final boolean isInfoEnabled() {
+
+        return isLevelEnabled(SimpleLogger.LOG_LEVEL_INFO);
+    }
+
+
+    /**
+     * <p> Are trace messages currently enabled? </p>
+     *
+     * <p> This allows expensive operations such as <code>String</code>
+     * concatenation to be avoided when the message will be ignored by the
+     * logger. </p>
+     */
+    public final boolean isTraceEnabled() {
+
+        return isLevelEnabled(SimpleLogger.LOG_LEVEL_TRACE);
+    }
+
+
+    /**
+     * <p> Are warn messages currently enabled? </p>
+     *
+     * <p> This allows expensive operations such as <code>String</code>
+     * concatenation to be avoided when the message will be ignored by the
+     * logger. </p>
+     */
+    public final boolean isWarnEnabled() {
+
+        return isLevelEnabled(SimpleLogger.LOG_LEVEL_WARN);
+    }
+}
+

Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleLogger.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/package.html
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/package.html?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/package.html
(added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/package.html
Mon May 23 03:46:05 2005
@@ -0,0 +1,21 @@
+<!--
+
+ Copyright 2001-2004 The Apache Software Foundation.
+ 
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<body>
+<p>Concrete implementations of commons-logging wrapper APIs.</p>
+</body>

Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/package.html
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/package.html?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/package.html
(added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/package.html
Mon May 23 03:46:05 2005
@@ -0,0 +1,256 @@
+<!--
+
+ Copyright 2001-2004 The Apache Software Foundation.
+ 
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<body>
+<p>Simple wrapper API around multiple logging APIs.</p>
+
+
+<h3>Overview</h3>
+
+<p>This package provides an API for logging in server-based applications that
+can be used around a variety of different logging implementations, including
+prebuilt support for the following:</p>
+<ul>
+<li><a href="http://logging.apache.org/log4j/">Log4J</a> (version 1.2 or
later)
+    from Apache's Jakarta project.  Each named <a href="Log.html">Log</a>
+    instance is connected to a corresponding Log4J Logger.</li>
+<li><a href="http://java.sun.com/j2se/1.4/docs/guide/util/logging/index.html">
+    JDK Logging API</a>, included in JDK 1.4 or later systems.  Each named
+    <a href="Log.html">Log</a> instance is connected to a corresponding
+    <code>java.util.logging.Logger</code> instance.</li>
+<li><a href="http://avalon.apache.org/logkit/">LogKit</a> from Apache's
+    Avalon project.  Each named <a href="Log.html">Log</a> instance is
+    connected to a corresponding LogKit <code>Logger</code>.</li>
+<li><a href="impl/NoOpLog.html">NoOpLog</a> implementation that simply
swallows
+    all log output, for all named <a href="Log.html">Log</a> instances.</li>
+<li><a href="impl/SimpleLog.html">SimpleLog</a> implementation that writes
all
+    log output, for all named <a href="Log.html">Log</a> instances, to
+    System.err.</li>
+</ul>
+
+<p>This library is intended to run on any JVM equal to or later than 
+version 1.1.</p>
+
+<h3>Quick Start Guide</h3>
+
+<p>For those impatient to just get on with it, the following example
+illustrates the typical declaration and use of a logger that is named (by
+convention) after the calling class:
+
+<pre>
+    import org.apache.commons.logging.Log;
+    import org.apache.commons.logging.LogFactory;
+
+    public class Foo {
+
+        static Log log = LogFactory.getLog(Foo.class);
+
+        public void foo() {
+            ...
+            try {
+                if (log.isDebugEnabled()) {
+                    log.debug("About to do something to object " + name);
+                }
+                name.bar();
+            } catch (IllegalStateException e) {
+                log.error("Something bad happened to " + name, e);
+            }
+            ...
+        }
+</pre>
+
+<p>Unless you configure things differently, all log output will be written
+to System.err.  Therefore, you really will want to review the remainder of
+this page in order to understand how to configure logging for your
+application.</p>
+
+
+<h3>Configuring the Commons Logging Package</h3>
+
+
+<h4>Choosing a <code>LogFactory</code> Implementation</h4>
+
+<p>From an application perspective, the first requirement is to retrieve an
+object reference to the <code>LogFactory</code> instance that will be used
+to create <code><a href="Log.html">Log</a></code> instances for this
+application.  This is normally accomplished by calling the static
+<code>getFactory()</code> method.  This method implements the following
+discovery algorithm to select the name of the <code>LogFactory</code>
+implementation class this application wants to use:</p>
+<ul>
+<li>Check for a system property named
+   <code>org.apache.commons.logging.LogFactory</code>.</li>
+<li>Use the JDK 1.3 JAR Services Discovery mechanism (see
+    <a href="http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html">
+    http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html</a> for
+    more information) to look for a resource named
+    <code>META-INF/services/org.apache.commons.logging.LogFactory</code>
+    whose first line is assumed to contain the desired class name.</li>
+<li>Look for a properties file named <code>commons-logging.properties</code>
+    visible in the application class path, with a property named
+    <code>org.apache.commons.logging.LogFactory</code> defining the
+    desired implementation class name.</li>
+<li>Fall back to a default implementation, which is described
+    further below.</li>
+</ul>
+
+<p>If a <code>commons-logging.properties</code> file is found, all of the
+properties defined there are also used to set configuration attributes on
+the instantiated <code>LogFactory</code> instance.</p>
+
+<p>Once an implementation class name is selected, the corresponding class is
+loaded from the current Thread context class loader (if there is one), or
+from the class loader that loaded the <code>LogFactory</code> class itself
+otherwise.  This allows a copy of <code>commons-logging.jar</code> to be
+shared in a multiple class loader environment (such as a servlet container),
+but still allow each web application to provide its own <code>LogFactory</code>
+implementation, if it so desires.  An instance of this class will then be
+created, and cached per class loader.
+
+
+<h4>The Default <code>LogFactory</code> Implementation</h4>
+
+<p>The Logging Package APIs include a default <code>LogFactory</code>
+implementation class (<a href="impl/LogFactoryImpl.html">
+org.apache.commons.logging.impl.LogFactoryImpl</a>) that is selected if no
+other implementation class name can be discovered.  Its primary purpose is
+to create (as necessary) and return <a href="Log.html">Log</a> instances
+in response to calls to the <code>getInstance()</code> method.  The default
+implementation uses the following rules:</p>
+<ul>
+<li>At most one <code>Log</code> instance of the same name will be created.
+    Subsequent <code>getInstance()</code> calls to the same
+    <code>LogFactory</code> instance, with the same name or <code>Class</code>
+    parameter, will return the same <code>Log</code> instance.</li>
+<li>When a new <code>Log</code> instance must be created, the default
+    <code>LogFactory</code> implementation uses the following discovery
+    process:
+    <ul>
+    <li>Look for a configuration attribute of this factory named
+        <code>org.apache.commons.logging.Log</code> (for backwards
+        compatibility to pre-1.0 versions of this API, an attribute
+        <code>org.apache.commons.logging.log</code> is also consulted).</li>
+    <li>Look for a system property named
+        <code>org.apache.commons.logging.Log</code> (for backwards
+        compatibility to pre-1.0 versions of this API, a system property
+        <code>org.apache.commons.logging.log</code> is also consulted).</li>
+    <li>If the Log4J logging system is available in the application
+        class path, use the corresponding wrapper class
+        (<a href="impl/Log4JLogger.html">Log4JLogger</a>).</li>
+    <li>If the application is executing on a JDK 1.4 system, use
+        the corresponding wrapper class
+        (<a href="impl/Jdk14Logger.html">Jdk14Logger</a>).</li>
+    <li>Fall back to the default simple logging implementation
+        (<a href="impl/SimpleLog.html">SimpleLog</a>).</li>
+    </ul></li>
+<li>Load the class of the specified name from the thread context class
+    loader (if any), or from the class loader that loaded the
+    <code>LogFactory</code> class otherwise.</li>
+<li>Instantiate an instance of the selected <code>Log</code>
+    implementation class, passing the specified name as the single
+    argument to its constructor.</li>
+</ul>
+
+<p>See the <a href="impl/SimpleLog.html">SimpleLog</a> JavaDocs for detailed
+configuration information for this default implementation.</p>
+
+
+<h4>Configuring the Underlying Logging System</h4>
+
+<p>The basic principle is that the user is totally responsible for the
+configuration of the underlying logging system.
+Commons-logging should not change the existing configuration.</p>
+
+<p>Each individual <a href="Log.html">Log</a> implementation may
+support its own configuration properties.  These will be documented in the
+class descriptions for the corresponding implementation class.</p>
+
+<p>Finally, some <code>Log</code> implementations (such as the one for
Log4J)
+require an external configuration file for the entire logging environment.
+This file should be prepared in a manner that is specific to the actual logging
+technology being used.</p>
+
+
+<h3>Using the Logging Package APIs</h3>
+
+<p>Use of the Logging Package APIs, from the perspective of an application
+component, consists of the following steps:</p>
+<ol>
+<li>Acquire a reference to an instance of
+    <a href="Log.html">org.apache.commons.logging.Log</a>, by calling the
+    factory method
+    <a href="LogFactory.html#getInstance(java.lang.String)">
+    LogFactory.getInstance(String name)</a>.  Your application can contain
+    references to multiple loggers that are used for different
+    purposes.  A typical scenario for a server application is to have each
+    major component of the server use its own Log instance.</li>
+<li>Cause messages to be logged (if the corresponding detail level is enabled)
+    by calling appropriate methods (<code>trace()</code>, <code>debug()</code>,
+    <code>info()</code>, <code>warn()</code>, <code>error</code>,
and
+    <code>fatal()</code>).</li>
+</ol>
+
+<p>For convenience, <code>LogFactory</code> also offers a static method
+<code>getLog()</code> that combines the typical two-step pattern:</p>
+<pre>
+  Log log = LogFactory.getFactory().getInstance(Foo.class);
+</pre>
+<p>into a single method call:</p>
+<pre>
+  Log log = LogFactory.getLog(Foo.class);
+</pre>
+
+<p>For example, you might use the following technique to initialize and
+use a <a href="Log.html">Log</a> instance in an application component:</p>
+<pre>
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class MyComponent {
+
+  protected static Log log =
+    LogFactory.getLog(MyComponent.class);
+
+  // Called once at startup time
+  public void start() {
+    ...
+    log.info("MyComponent started");
+    ...
+  }
+
+  // Called once at shutdown time
+  public void stop() {
+    ...
+    log.info("MyComponent stopped");
+    ...
+  }
+
+  // Called repeatedly to process a particular argument value
+  // which you want logged if debugging is enabled
+  public void process(String value) {
+    ...
+    // Do the string concatenation only if logging is enabled
+    if (log.isDebugEnabled())
+      log.debug("MyComponent processing " + value);
+    ...
+  }
+
+}
+</pre>
+
+</body>

Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/overview.html
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/overview.html?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/overview.html (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/overview.html Mon May 23 03:46:05
2005
@@ -0,0 +1,34 @@
+<!--
+
+ Copyright 2001-2004 The Apache Software Foundation.
+ 
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<html>
+<head>
+<title>Overview Documentation for COMMONS-LOGGING</title>
+</head>
+<body bgcolor="white">
+<p>The <em>Logging Wrapper Library</em> component of the Jakarta Commons
+subproject offers wrappers around an extensible set of concrete logging
+implementations, so that application code based on it does not need to be
+modified in order to select a different logging implementation.</p>
+
+<p>See the
+<a href="org/apache/commons/logging/package-summary.html#package_description">
+Package Description</a> for the <code>org.apache.commons.logging</code>
+package for more information.</p>
+</body>
+</html>

Added: jakarta/commons/proper/logging/branches/simon-1.1/src/media/logo.png
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/media/logo.png?rev=177949&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/media/logo.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: jakarta/commons/proper/logging/branches/simon-1.1/src/media/logo.xcf
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/media/logo.xcf?rev=177949&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/media/logo.xcf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message