Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2F964F57E for ; Tue, 19 Mar 2013 21:15:57 +0000 (UTC) Received: (qmail 25838 invoked by uid 500); 19 Mar 2013 21:15:55 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 25727 invoked by uid 500); 19 Mar 2013 21:15:55 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 25683 invoked by uid 99); 19 Mar 2013 21:15:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Mar 2013 21:15:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Mar 2013 21:15:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2CEC82388BA4 for ; Tue, 19 Mar 2013 21:14:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r855121 [17/22] - in /websites/production/commons/content/proper/commons-logging/javadocs/api-release: ./ org/ org/apache/ org/apache/commons/ org/apache/commons/logging/ org/apache/commons/logging/class-use/ org/apache/commons/logging/impl... Date: Tue, 19 Mar 2013 21:14:40 -0000 To: commits@commons.apache.org From: tn@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130319211444.2CEC82388BA4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/LogFactory.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/LogFactory.html ------------------------------------------------------------------------------ svn:keywords = Id Revision HeadURL Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/LogFactory.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/LogSource.html ============================================================================== --- websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/LogSource.html (added) +++ websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/LogSource.html Tue Mar 19 21:14:39 2013 @@ -0,0 +1,291 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements.  See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache License, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License.  You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the License for the specific language governing permissions and
+015 * limitations under the License.
+016 */
+017
+018package org.apache.commons.logging;
+019
+020import java.lang.reflect.Constructor;
+021import java.util.Hashtable;
+022
+023import org.apache.commons.logging.impl.NoOpLog;
+024
+025/**
+026 * Factory for creating {@link Log} instances.  Applications should call
+027 * the <code>makeNewLogInstance()</code> method to instantiate new instances
+028 * of the configured {@link Log} implementation class.
+029 * <p>
+030 * By default, calling <code>getInstance()</code> will use the following
+031 * algorithm:
+032 * <ul>
+033 * <li>If Log4J is available, return an instance of
+034 *     <code>org.apache.commons.logging.impl.Log4JLogger</code>.</li>
+035 * <li>If JDK 1.4 or later is available, return an instance of
+036 *     <code>org.apache.commons.logging.impl.Jdk14Logger</code>.</li>
+037 * <li>Otherwise, return an instance of
+038 *     <code>org.apache.commons.logging.impl.NoOpLog</code>.</li>
+039 * </ul>
+040 * <p>
+041 * You can change the default behavior in one of two ways:
+042 * <ul>
+043 * <li>On the startup command line, set the system property
+044 *     <code>org.apache.commons.logging.log</code> to the name of the
+045 *     <code>org.apache.commons.logging.Log</code> implementation class
+046 *     you want to use.</li>
+047 * <li>At runtime, call <code>LogSource.setLogImplementation()</code>.</li>
+048 * </ul>
+049 *
+050 * @deprecated Use {@link LogFactory} instead - The default factory
+051 *  implementation performs exactly the same algorithm as this class did
+052 *
+053 * @version $Id$
+054 */
+055public class LogSource {
+056
+057    // ------------------------------------------------------- Class Attributes
+058
+059    static protected Hashtable logs = new Hashtable();
+060
+061    /** Is log4j available (in the current classpath) */
+062    static protected boolean log4jIsAvailable = false;
+063
+064    /** Is JDK 1.4 logging available */
+065    static protected boolean jdk14IsAvailable = false;
+066
+067    /** Constructor for current log class */
+068    static protected Constructor logImplctor = null;
+069
+070    // ----------------------------------------------------- Class Initializers
+071
+072    static {
+073
+074        // Is Log4J Available?
+075        try {
+076            log4jIsAvailable = null != Class.forName("org.apache.log4j.Logger");
+077        } catch (Throwable t) {
+078            log4jIsAvailable = false;
+079        }
+080
+081        // Is JDK 1.4 Logging Available?
+082        try {
+083            jdk14IsAvailable = null != Class.forName("java.util.logging.Logger") &&
+084                               null != Class.forName("org.apache.commons.logging.impl.Jdk14Logger");
+085        } catch (Throwable t) {
+086            jdk14IsAvailable = false;
+087        }
+088
+089        // Set the default Log implementation
+090        String name = null;
+091        try {
+092            name = System.getProperty("org.apache.commons.logging.log");
+093            if (name == null) {
+094                name = System.getProperty("org.apache.commons.logging.Log");
+095            }
+096        } catch (Throwable t) {
+097        }
+098        if (name != null) {
+099            try {
+100                setLogImplementation(name);
+101            } catch (Throwable t) {
+102                try {
+103                    setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
+104                } catch (Throwable u) {
+105                    // ignored
+106                }
+107            }
+108        } else {
+109            try {
+110                if (log4jIsAvailable) {
+111                    setLogImplementation("org.apache.commons.logging.impl.Log4JLogger");
+112                } else if (jdk14IsAvailable) {
+113                    setLogImplementation("org.apache.commons.logging.impl.Jdk14Logger");
+114                } else {
+115                    setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
+116                }
+117            } catch (Throwable t) {
+118                try {
+119                    setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
+120                } catch (Throwable u) {
+121                    // ignored
+122                }
+123            }
+124        }
+125
+126    }
+127
+128    // ------------------------------------------------------------ Constructor
+129
+130    /** Don't allow others to create instances. */
+131    private LogSource() {
+132    }
+133
+134    // ---------------------------------------------------------- Class Methods
+135
+136    /**
+137     * Set the log implementation/log implementation factory
+138     * by the name of the class.  The given class must implement {@link Log},
+139     * and provide a constructor that takes a single {@link String} argument
+140     * (containing the name of the log).
+141     */
+142    static public void setLogImplementation(String classname)
+143        throws LinkageError, NoSuchMethodException, SecurityException, ClassNotFoundException {
+144        try {
+145            Class logclass = Class.forName(classname);
+146            Class[] argtypes = new Class[1];
+147            argtypes[0] = "".getClass();
+148            logImplctor = logclass.getConstructor(argtypes);
+149        } catch (Throwable t) {
+150            logImplctor = null;
+151        }
+152    }
+153
+154    /**
+155     * Set the log implementation/log implementation factory by class.
+156     * The given class must implement {@link Log}, and provide a constructor
+157     * that takes a single {@link String} argument (containing the name of the log).
+158     */
+159    static public void setLogImplementation(Class logclass)
+160        throws LinkageError, ExceptionInInitializerError, NoSuchMethodException, SecurityException {
+161        Class[] argtypes = new Class[1];
+162        argtypes[0] = "".getClass();
+163        logImplctor = logclass.getConstructor(argtypes);
+164    }
+165
+166    /** Get a <code>Log</code> instance by class name. */
+167    static public Log getInstance(String name) {
+168        Log log = (Log) logs.get(name);
+169        if (null == log) {
+170            log = makeNewLogInstance(name);
+171            logs.put(name, log);
+172        }
+173        return log;
+174    }
+175
+176    /** Get a <code>Log</code> instance by class. */
+177    static public Log getInstance(Class clazz) {
+178        return getInstance(clazz.getName());
+179    }
+180
+181    /**
+182     * Create a new {@link Log} implementation, based on the given <i>name</i>.
+183     * <p>
+184     * The specific {@link Log} implementation returned is determined by the
+185     * value of the <tt>org.apache.commons.logging.log</tt> property. The value
+186     * of <tt>org.apache.commons.logging.log</tt> may be set to the fully specified
+187     * name of a class that implements the {@link Log} interface. This class must
+188     * also have a public constructor that takes a single {@link String} argument
+189     * (containing the <i>name</i> of the {@link Log} to be constructed.
+190     * <p>
+191     * When <tt>org.apache.commons.logging.log</tt> is not set, or when no corresponding
+192     * class can be found, this method will return a Log4JLogger if the log4j Logger
+193     * class is available in the {@link LogSource}'s classpath, or a Jdk14Logger if we
+194     * are on a JDK 1.4 or later system, or NoOpLog if neither of the above conditions is true.
+195     *
+196     * @param name the log name (or category)
+197     */
+198    static public Log makeNewLogInstance(String name) {
+199        Log log;
+200        try {
+201            Object[] args = { name };
+202            log = (Log) logImplctor.newInstance(args);
+203        } catch (Throwable t) {
+204            log = null;
+205        }
+206        if (null == log) {
+207            log = new NoOpLog(name);
+208        }
+209        return log;
+210    }
+211
+212    /**
+213     * Returns a {@link String} array containing the names of
+214     * all logs known to me.
+215     */
+216    static public String[] getLogNames() {
+217        return (String[]) logs.keySet().toArray(new String[logs.size()]);
+218    }
+219}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/LogSource.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/LogSource.html ------------------------------------------------------------------------------ svn:keywords = Id Revision HeadURL Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/LogSource.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/AvalonLogger.html ============================================================================== --- websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/AvalonLogger.html (added) +++ websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/AvalonLogger.html Tue Mar 19 21:14:39 2013 @@ -0,0 +1,370 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements.  See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache License, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License.  You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the License for the specific language governing permissions and
+015 * limitations under the License.
+016 */
+017
+018package org.apache.commons.logging.impl;
+019
+020import org.apache.avalon.framework.logger.Logger;
+021import org.apache.commons.logging.Log;
+022
+023/**
+024 * Implementation of commons-logging Log interface that delegates all
+025 * logging calls to the Avalon logging abstraction: the Logger interface.
+026 * <p>
+027 * There are two ways in which this class can be used:
+028 * <ul>
+029 * <li>the instance can be constructed with an Avalon logger
+030 * (by calling {@link #AvalonLogger(Logger)}). In this case, it acts
+031 * as a simple thin wrapping implementation over the logger. This is
+032 * particularly useful when using a property setter.
+033 * </li>
+034 * <li>the {@link #setDefaultLogger} class property can be called which
+035 * sets the ancestral Avalon logger for this class. Any <code>AvalonLogger</code>
+036 * instances created through the <code>LogFactory</code> mechanisms will output
+037 * to child loggers of this <code>Logger</code>.
+038 * </li>
+039 * </ul>
+040 * <p>
+041 * <strong>Note:</strong> <code>AvalonLogger</code> does not implement Serializable
+042 * because the constructors available for it make this impossible to achieve in all
+043 * circumstances; there is no way to "reconnect" to an underlying Logger object on
+044 * deserialization if one was just passed in to the constructor of the original
+045 * object. This class <i>was</i> marked Serializable in the 1.0.4 release of
+046 * commons-logging, but this never actually worked (a NullPointerException would
+047 * be thrown as soon as the deserialized object was used), so removing this marker
+048 * is not considered to be an incompatible change.
+049 *
+050 * @version $Id$
+051 */
+052public class AvalonLogger implements Log {
+053
+054    /** Ancestral Avalon logger. */
+055    private static volatile Logger defaultLogger = null;
+056    /** Avalon logger used to perform log. */
+057    private final transient Logger logger;
+058
+059    /**
+060     * Constructs an <code>AvalonLogger</code> that outputs to the given
+061     * <code>Logger</code> instance.
+062     *
+063     * @param logger the Avalon logger implementation to delegate to
+064     */
+065    public AvalonLogger(Logger logger) {
+066        this.logger = logger;
+067    }
+068
+069    /**
+070     * Constructs an <code>AvalonLogger</code> that will log to a child
+071     * of the <code>Logger</code> set by calling {@link #setDefaultLogger}.
+072     *
+073     * @param name the name of the avalon logger implementation to delegate to
+074     */
+075    public AvalonLogger(String name) {
+076        if (defaultLogger == null) {
+077            throw new NullPointerException("default logger has to be specified if this constructor is used!");
+078        }
+079        this.logger = defaultLogger.getChildLogger(name);
+080    }
+081
+082    /**
+083     * Gets the Avalon logger implementation used to perform logging.
+084     *
+085     * @return avalon logger implementation
+086     */
+087    public Logger getLogger() {
+088        return logger;
+089    }
+090
+091    /**
+092     * Sets the ancestral Avalon logger from which the delegating loggers will descend.
+093     *
+094     * @param logger the default avalon logger,
+095     * in case there is no logger instance supplied in constructor
+096     */
+097    public static void setDefaultLogger(Logger logger) {
+098        defaultLogger = logger;
+099    }
+100
+101    /**
+102    * Logs a message with <code>org.apache.avalon.framework.logger.Logger.debug</code>.
+103    *
+104    * @param message to log
+105    * @param t log this cause
+106    * @see org.apache.commons.logging.Log#debug(Object, Throwable)
+107     */
+108    public void debug(Object message, Throwable t) {
+109        if (getLogger().isDebugEnabled()) {
+110            getLogger().debug(String.valueOf(message), t);
+111        }
+112    }
+113
+114    /**
+115     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.debug</code>.
+116     *
+117     * @param message to log.
+118     * @see org.apache.commons.logging.Log#debug(Object)
+119     */
+120    public void debug(Object message) {
+121        if (getLogger().isDebugEnabled()) {
+122            getLogger().debug(String.valueOf(message));
+123        }
+124    }
+125
+126    /**
+127     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.error</code>.
+128     *
+129     * @param message to log
+130     * @param t log this cause
+131     * @see org.apache.commons.logging.Log#error(Object, Throwable)
+132     */
+133    public void error(Object message, Throwable t) {
+134        if (getLogger().isErrorEnabled()) {
+135            getLogger().error(String.valueOf(message), t);
+136        }
+137    }
+138
+139    /**
+140     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.error</code>.
+141     *
+142     * @param message to log
+143     * @see org.apache.commons.logging.Log#error(Object)
+144     */
+145    public void error(Object message) {
+146        if (getLogger().isErrorEnabled()) {
+147            getLogger().error(String.valueOf(message));
+148        }
+149    }
+150
+151    /**
+152     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.fatalError</code>.
+153     *
+154     * @param message to log.
+155     * @param t log this cause.
+156     * @see org.apache.commons.logging.Log#fatal(Object, Throwable)
+157     */
+158    public void fatal(Object message, Throwable t) {
+159        if (getLogger().isFatalErrorEnabled()) {
+160            getLogger().fatalError(String.valueOf(message), t);
+161        }
+162    }
+163
+164    /**
+165     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.fatalError</code>.
+166     *
+167     * @param message to log
+168     * @see org.apache.commons.logging.Log#fatal(Object)
+169     */
+170    public void fatal(Object message) {
+171        if (getLogger().isFatalErrorEnabled()) {
+172            getLogger().fatalError(String.valueOf(message));
+173        }
+174    }
+175
+176    /**
+177     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.info</code>.
+178     *
+179     * @param message to log
+180     * @param t log this cause
+181     * @see org.apache.commons.logging.Log#info(Object, Throwable)
+182     */
+183    public void info(Object message, Throwable t) {
+184        if (getLogger().isInfoEnabled()) {
+185            getLogger().info(String.valueOf(message), t);
+186        }
+187    }
+188
+189    /**
+190     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.info</code>.
+191     *
+192     * @param message to log
+193     * @see org.apache.commons.logging.Log#info(Object)
+194     */
+195    public void info(Object message) {
+196        if (getLogger().isInfoEnabled()) {
+197            getLogger().info(String.valueOf(message));
+198        }
+199    }
+200
+201    /**
+202     * Is logging to <code>org.apache.avalon.framework.logger.Logger.debug</code> enabled?
+203     * @see org.apache.commons.logging.Log#isDebugEnabled()
+204     */
+205    public boolean isDebugEnabled() {
+206        return getLogger().isDebugEnabled();
+207    }
+208
+209    /**
+210     * Is logging to <code>org.apache.avalon.framework.logger.Logger.error</code> enabled?
+211     * @see org.apache.commons.logging.Log#isErrorEnabled()
+212     */
+213    public boolean isErrorEnabled() {
+214        return getLogger().isErrorEnabled();
+215    }
+216
+217    /**
+218     * Is logging to <code>org.apache.avalon.framework.logger.Logger.fatalError</code> enabled?
+219     * @see org.apache.commons.logging.Log#isFatalEnabled()
+220     */
+221    public boolean isFatalEnabled() {
+222        return getLogger().isFatalErrorEnabled();
+223    }
+224
+225    /**
+226     * Is logging to <code>org.apache.avalon.framework.logger.Logger.info</code> enabled?
+227     * @see org.apache.commons.logging.Log#isInfoEnabled()
+228     */
+229    public boolean isInfoEnabled() {
+230        return getLogger().isInfoEnabled();
+231    }
+232
+233    /**
+234     * Is logging to <code>org.apache.avalon.framework.logger.Logger.debug</code> enabled?
+235     * @see org.apache.commons.logging.Log#isTraceEnabled()
+236     */
+237    public boolean isTraceEnabled() {
+238        return getLogger().isDebugEnabled();
+239    }
+240
+241    /**
+242     * Is logging to <code>org.apache.avalon.framework.logger.Logger.warn</code> enabled?
+243     * @see org.apache.commons.logging.Log#isWarnEnabled()
+244     */
+245    public boolean isWarnEnabled() {
+246        return getLogger().isWarnEnabled();
+247    }
+248
+249    /**
+250     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.debug</code>.
+251     *
+252     * @param message to log.
+253     * @param t log this cause.
+254     * @see org.apache.commons.logging.Log#trace(Object, Throwable)
+255     */
+256    public void trace(Object message, Throwable t) {
+257        if (getLogger().isDebugEnabled()) {
+258            getLogger().debug(String.valueOf(message), t);
+259        }
+260    }
+261
+262    /**
+263     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.debug</code>.
+264     *
+265     * @param message to log
+266     * @see org.apache.commons.logging.Log#trace(Object)
+267     */
+268    public void trace(Object message) {
+269        if (getLogger().isDebugEnabled()) {
+270            getLogger().debug(String.valueOf(message));
+271        }
+272    }
+273
+274    /**
+275     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.warn</code>.
+276     *
+277     * @param message to log
+278     * @param t log this cause
+279     * @see org.apache.commons.logging.Log#warn(Object, Throwable)
+280     */
+281    public void warn(Object message, Throwable t) {
+282        if (getLogger().isWarnEnabled()) {
+283            getLogger().warn(String.valueOf(message), t);
+284        }
+285    }
+286
+287    /**
+288     * Logs a message with <code>org.apache.avalon.framework.logger.Logger.warn</code>.
+289     *
+290     * @param message to log
+291     * @see org.apache.commons.logging.Log#warn(Object)
+292     */
+293    public void warn(Object message) {
+294        if (getLogger().isWarnEnabled()) {
+295            getLogger().warn(String.valueOf(message));
+296        }
+297    }
+298}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/AvalonLogger.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/AvalonLogger.html ------------------------------------------------------------------------------ svn:keywords = Id Revision HeadURL Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/AvalonLogger.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/Jdk13LumberjackLogger.html ============================================================================== --- websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/Jdk13LumberjackLogger.html (added) +++ websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/Jdk13LumberjackLogger.html Tue Mar 19 21:14:39 2013 @@ -0,0 +1,374 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements.  See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache License, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License.  You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the License for the specific language governing permissions and
+015 * limitations under the License.
+016 */
+017
+018package org.apache.commons.logging.impl;
+019
+020import java.io.Serializable;
+021import java.util.logging.Level;
+022import java.util.logging.Logger;
+023import java.util.logging.LogRecord;
+024import java.util.StringTokenizer;
+025import java.io.PrintWriter;
+026import java.io.StringWriter;
+027
+028import org.apache.commons.logging.Log;
+029
+030/**
+031 * Implementation of the <code>org.apache.commons.logging.Log</code>
+032 * interface that wraps the standard JDK logging mechanisms that are
+033 * available in SourceForge's Lumberjack for JDKs prior to 1.4.
+034 *
+035 * @version $Id$
+036 * @since 1.1
+037 */
+038public class Jdk13LumberjackLogger implements Log, Serializable {
+039
+040    /** Serializable version identifier. */
+041    private static final long serialVersionUID = -8649807923527610591L;
+042
+043    // ----------------------------------------------------- Instance Variables
+044
+045    /**
+046     * The underlying Logger implementation we are using.
+047     */
+048    protected transient Logger logger = null;
+049    protected String name = null;
+050    private String sourceClassName = "unknown";
+051    private String sourceMethodName = "unknown";
+052    private boolean classAndMethodFound = false;
+053
+054    /**
+055     * This member variable simply ensures that any attempt to initialise
+056     * this class in a pre-1.4 JVM will result in an ExceptionInInitializerError.
+057     * It must not be private, as an optimising compiler could detect that it
+058     * is not used and optimise it away.
+059     */
+060    protected static final Level dummyLevel = Level.FINE;
+061
+062    // ----------------------------------------------------------- Constructors
+063
+064    /**
+065     * Construct a named instance of this Logger.
+066     *
+067     * @param name Name of the logger to be constructed
+068     */
+069    public Jdk13LumberjackLogger(String name) {
+070        this.name = name;
+071        logger = getLogger();
+072    }
+073
+074    // --------------------------------------------------------- Public Methods
+075
+076    private void log( Level level, String msg, Throwable ex ) {
+077        if( getLogger().isLoggable(level) ) {
+078            LogRecord record = new LogRecord(level, msg);
+079            if( !classAndMethodFound ) {
+080                getClassAndMethod();
+081            }
+082            record.setSourceClassName(sourceClassName);
+083            record.setSourceMethodName(sourceMethodName);
+084            if( ex != null ) {
+085                record.setThrown(ex);
+086            }
+087            getLogger().log(record);
+088        }
+089    }
+090
+091    /**
+092     * Gets the class and method by looking at the stack trace for the
+093     * first entry that is not this class.
+094     */
+095    private void getClassAndMethod() {
+096        try {
+097            Throwable throwable = new Throwable();
+098            throwable.fillInStackTrace();
+099            StringWriter stringWriter = new StringWriter();
+100            PrintWriter printWriter = new PrintWriter( stringWriter );
+101            throwable.printStackTrace( printWriter );
+102            String traceString = stringWriter.getBuffer().toString();
+103            StringTokenizer tokenizer =
+104                new StringTokenizer( traceString, "\n" );
+105            tokenizer.nextToken();
+106            String line = tokenizer.nextToken();
+107            while ( line.indexOf( this.getClass().getName() )  == -1 ) {
+108                line = tokenizer.nextToken();
+109            }
+110            while ( line.indexOf( this.getClass().getName() ) >= 0 ) {
+111                line = tokenizer.nextToken();
+112            }
+113            int start = line.indexOf( "at " ) + 3;
+114            int end = line.indexOf( '(' );
+115            String temp = line.substring( start, end );
+116            int lastPeriod = temp.lastIndexOf( '.' );
+117            sourceClassName = temp.substring( 0, lastPeriod );
+118            sourceMethodName = temp.substring( lastPeriod + 1 );
+119        } catch ( Exception ex ) {
+120            // ignore - leave class and methodname unknown
+121        }
+122        classAndMethodFound = true;
+123    }
+124
+125    /**
+126     * Logs a message with <code>java.util.logging.Level.FINE</code>.
+127     *
+128     * @param message to log
+129     * @see org.apache.commons.logging.Log#debug(Object)
+130     */
+131    public void debug(Object message) {
+132        log(Level.FINE, String.valueOf(message), null);
+133    }
+134
+135    /**
+136     * Logs a message with <code>java.util.logging.Level.FINE</code>.
+137     *
+138     * @param message to log
+139     * @param exception log this cause
+140     * @see org.apache.commons.logging.Log#debug(Object, Throwable)
+141     */
+142    public void debug(Object message, Throwable exception) {
+143        log(Level.FINE, String.valueOf(message), exception);
+144    }
+145
+146    /**
+147     * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
+148     *
+149     * @param message to log
+150     * @see org.apache.commons.logging.Log#error(Object)
+151     */
+152    public void error(Object message) {
+153        log(Level.SEVERE, String.valueOf(message), null);
+154    }
+155
+156    /**
+157     * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
+158     *
+159     * @param message to log
+160     * @param exception log this cause
+161     * @see org.apache.commons.logging.Log#error(Object, Throwable)
+162     */
+163    public void error(Object message, Throwable exception) {
+164        log(Level.SEVERE, String.valueOf(message), exception);
+165    }
+166
+167    /**
+168     * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
+169     *
+170     * @param message to log
+171     * @see org.apache.commons.logging.Log#fatal(Object)
+172     */
+173    public void fatal(Object message) {
+174        log(Level.SEVERE, String.valueOf(message), null);
+175    }
+176
+177    /**
+178     * Logs a message with <code>java.util.logging.Level.SEVERE</code>.
+179     *
+180     * @param message to log
+181     * @param exception log this cause
+182     * @see org.apache.commons.logging.Log#fatal(Object, Throwable)
+183     */
+184    public void fatal(Object message, Throwable exception) {
+185        log(Level.SEVERE, String.valueOf(message), exception);
+186    }
+187
+188    /**
+189     * Return the native Logger instance we are using.
+190     */
+191    public Logger getLogger() {
+192        if (logger == null) {
+193            logger = Logger.getLogger(name);
+194        }
+195        return logger;
+196    }
+197
+198    /**
+199     * Logs a message with <code>java.util.logging.Level.INFO</code>.
+200     *
+201     * @param message to log
+202     * @see org.apache.commons.logging.Log#info(Object)
+203     */
+204    public void info(Object message) {
+205        log(Level.INFO, String.valueOf(message), null);
+206    }
+207
+208    /**
+209     * Logs a message with <code>java.util.logging.Level.INFO</code>.
+210     *
+211     * @param message to log
+212     * @param exception log this cause
+213     * @see org.apache.commons.logging.Log#info(Object, Throwable)
+214     */
+215    public void info(Object message, Throwable exception) {
+216        log(Level.INFO, String.valueOf(message), exception);
+217    }
+218
+219    /**
+220     * Is debug logging currently enabled?
+221     */
+222    public boolean isDebugEnabled() {
+223        return getLogger().isLoggable(Level.FINE);
+224    }
+225
+226    /**
+227     * Is error logging currently enabled?
+228     */
+229    public boolean isErrorEnabled() {
+230        return getLogger().isLoggable(Level.SEVERE);
+231    }
+232
+233    /**
+234     * Is fatal logging currently enabled?
+235     */
+236    public boolean isFatalEnabled() {
+237        return getLogger().isLoggable(Level.SEVERE);
+238    }
+239
+240    /**
+241     * Is info logging currently enabled?
+242     */
+243    public boolean isInfoEnabled() {
+244        return getLogger().isLoggable(Level.INFO);
+245    }
+246
+247    /**
+248     * Is trace logging currently enabled?
+249     */
+250    public boolean isTraceEnabled() {
+251        return getLogger().isLoggable(Level.FINEST);
+252    }
+253
+254    /**
+255     * Is warn logging currently enabled?
+256     */
+257    public boolean isWarnEnabled() {
+258        return getLogger().isLoggable(Level.WARNING);
+259    }
+260
+261    /**
+262     * Logs a message with <code>java.util.logging.Level.FINEST</code>.
+263     *
+264     * @param message to log
+265     * @see org.apache.commons.logging.Log#trace(Object)
+266     */
+267    public void trace(Object message) {
+268        log(Level.FINEST, String.valueOf(message), null);
+269    }
+270
+271    /**
+272     * Logs a message with <code>java.util.logging.Level.FINEST</code>.
+273     *
+274     * @param message to log
+275     * @param exception log this cause
+276     * @see org.apache.commons.logging.Log#trace(Object, Throwable)
+277     */
+278    public void trace(Object message, Throwable exception) {
+279        log(Level.FINEST, String.valueOf(message), exception);
+280    }
+281
+282    /**
+283     * Logs a message with <code>java.util.logging.Level.WARNING</code>.
+284     *
+285     * @param message to log
+286     * @see org.apache.commons.logging.Log#warn(Object)
+287     */
+288    public void warn(Object message) {
+289        log(Level.WARNING, String.valueOf(message), null);
+290    }
+291
+292    /**
+293     * Logs a message with <code>java.util.logging.Level.WARNING</code>.
+294     *
+295     * @param message to log
+296     * @param exception log this cause
+297     * @see org.apache.commons.logging.Log#warn(Object, Throwable)
+298     */
+299    public void warn(Object message, Throwable exception) {
+300        log(Level.WARNING, String.valueOf(message), exception);
+301    }
+302}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/Jdk13LumberjackLogger.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/Jdk13LumberjackLogger.html ------------------------------------------------------------------------------ svn:keywords = Id Revision HeadURL Propchange: websites/production/commons/content/proper/commons-logging/javadocs/api-release/src-html/org/apache/commons/logging/impl/Jdk13LumberjackLogger.html ------------------------------------------------------------------------------ svn:mime-type = text/html