001    /*
002     * HapiLogFactory.java
003     * 
004     * Created on May 7, 2003 at 2:19:17 PM
005     */
006    package ca.uhn.log;
007    
008    import org.apache.commons.logging.Log;
009    import org.apache.commons.logging.LogFactory;
010    
011    /**
012     * <p>Factory for creating {@link HapiLog} instances. It is factory
013     * that delegates the discovery process to the <code> LogFactory </code>
014     * class and wraps the discovered <code> Log </code> with a new instance of
015     * the <code>HapiLog</code> class.
016     * 
017     * @author <a href="mailto:alexei.guevara@uhn.on.ca">Alexei Guevara</a>
018     * @version $Revision: 1.1 $ updated on $Date: 2007/02/19 02:24:52 $ by $Author: jamesagnew $
019     */
020    public final class HapiLogFactory {
021        
022        /**
023         * Do not allow instantiation.
024         */
025        private HapiLogFactory() {
026        }
027    
028        /**
029         * Convenience method to return a named HAPI logger, without the application
030         * having to care about factories.
031         *
032         * @param clazz Class for which a log name will be derived
033         *
034         * @exception LogConfigurationException if a suitable <code>Log</code>
035         *  instance cannot be returned
036         */
037        public static HapiLog getHapiLog( Class clazz ) {
038            HapiLog retVal = null;
039            
040            Log log = LogFactory.getLog( clazz );
041            retVal = new HapiLogImpl( log );
042            
043            return retVal;
044            
045        }
046        
047        /**
048         * Convenience method to return a named HAPI logger, without the application
049         * having to care about factories.
050         *
051         * @param name Logical name of the <code>Log</code> instance to be
052         *  returned (the meaning of this name is only known to the underlying
053         *  logging implementation that is being wrapped)
054         *
055         * @exception LogConfigurationException if a suitable <code>Log</code>
056         *  instance cannot be returned
057         */
058        public static HapiLog getHapiLog( String name ) {
059            HapiLog retVal = null;
060            
061            Log log = LogFactory.getLog( name );
062            retVal = new HapiLogImpl( log );
063            
064            return retVal;
065        }
066    
067    }
068    
069