001/*
002 *  jDTAUS Core RI Commons Logging
003 *  Copyright (C) 2005 Christian Schulte
004 *  <cs@schulte.it>
005 *
006 *  This library is free software; you can redistribute it and/or
007 *  modify it under the terms of the GNU Lesser General Public
008 *  License as published by the Free Software Foundation; either
009 *  version 2.1 of the License, or any later version.
010 *
011 *  This library is distributed in the hope that it will be useful,
012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 *  Lesser General Public License for more details.
015 *
016 *  You should have received a copy of the GNU Lesser General Public
017 *  License along with this library; if not, write to the Free Software
018 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
019 *
020 */
021package org.jdtaus.core.logging.ri.commons;
022
023import org.apache.commons.logging.Log;
024import org.apache.commons.logging.LogFactory;
025import org.jdtaus.core.container.ContainerFactory;
026import org.jdtaus.core.logging.spi.Logger;
027
028/**
029 * jDTAUS Core SPI Commons Logging {@code Logger} implementation.
030 * <p>The name of the commons logger is specified by property {@code name}.
031 * Property {@code name} defaults to {@code org.jdtaus.runtime}.</p>
032 *
033 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
034 * @version $JDTAUS: CommonsLoggingLogger.java 8641 2012-09-27 06:45:17Z schulte $
035 *
036 * @see org.jdtaus.core.container.Container
037 */
038public class CommonsLoggingLogger implements Logger
039{
040    //--Constructors------------------------------------------------------------
041
042// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausConstructors
043    // This section is managed by jdtaus-container-mojo.
044
045    /** Standard implementation constructor <code>org.jdtaus.core.logging.ri.commons.CommonsLoggingLogger</code>. */
046    public CommonsLoggingLogger()
047    {
048        super();
049    }
050
051// </editor-fold>//GEN-END:jdtausConstructors
052
053    //------------------------------------------------------------Constructors--
054    //--Properties--------------------------------------------------------------
055
056// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausProperties
057    // This section is managed by jdtaus-container-mojo.
058
059    /**
060     * Gets the value of property <code>name</code>.
061     *
062     * @return Name uniquely identifying the logger.
063     */
064    public java.lang.String getName()
065    {
066        return (java.lang.String) ContainerFactory.getContainer().
067            getProperty( this, "name" );
068
069    }
070
071// </editor-fold>//GEN-END:jdtausProperties
072
073    //--------------------------------------------------------------Properties--
074    //--Logger------------------------------------------------------------------
075
076    public boolean isDebugEnabled()
077    {
078        return this.getLogger().isDebugEnabled();
079    }
080
081    public void debug( String message )
082    {
083        this.getLogger().debug( message );
084    }
085
086    public void debug( Throwable throwable )
087    {
088        this.getLogger().debug( throwable.getMessage(), throwable );
089    }
090
091    public boolean isErrorEnabled()
092    {
093        return this.getLogger().isErrorEnabled();
094    }
095
096    public void error( String message )
097    {
098        this.getLogger().error( message );
099    }
100
101    public void error( Throwable throwable )
102    {
103        this.getLogger().error( throwable.getMessage(), throwable );
104    }
105
106    public boolean isFatalEnabled()
107    {
108        return this.getLogger().isFatalEnabled();
109    }
110
111    public void fatal( String message )
112    {
113        this.getLogger().fatal( message );
114    }
115
116    public void fatal( Throwable throwable )
117    {
118        this.getLogger().fatal( throwable.getMessage(), throwable );
119    }
120
121    public boolean isInfoEnabled()
122    {
123        return this.getLogger().isInfoEnabled();
124    }
125
126    public void info( String message )
127    {
128        this.getLogger().info( message );
129    }
130
131    public void info( Throwable throwable )
132    {
133        this.getLogger().info( throwable.getMessage(), throwable );
134    }
135
136    public boolean isTraceEnabled()
137    {
138        return this.getLogger().isTraceEnabled();
139    }
140
141    public void trace( String message )
142    {
143        this.getLogger().trace( message );
144    }
145
146    public void trace( Throwable throwable )
147    {
148        this.getLogger().trace( throwable.getMessage(), throwable );
149    }
150
151    public boolean isWarnEnabled()
152    {
153        return this.getLogger().isWarnEnabled();
154    }
155
156    public void warn( String message )
157    {
158        this.getLogger().warn( message );
159    }
160
161    public void warn( Throwable throwable )
162    {
163        this.getLogger().warn( throwable.getMessage(), throwable );
164    }
165
166    //------------------------------------------------------------------Logger--
167    //--CommonsLoggingLogger----------------------------------------------------
168
169    /**
170     * Requests a commons logging logger for the name given by property
171     * {@code name}.
172     *
173     * @return the commons logging logger for the name given by property
174     * {@code name}.
175     */
176    public Log getLogger()
177    {
178        return LogFactory.getLog( this.getName() );
179    }
180
181    //----------------------------------------------------CommonsLoggingLogger--
182}