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