| 1 | /* |
| 2 | * jDTAUS Core RI Commons Logging |
| 3 | * Copyright (C) 2005 Christian Schulte |
| 4 | * <cs@schulte.it> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | * |
| 20 | */ |
| 21 | package org.jdtaus.core.logging.ri.commons; |
| 22 | |
| 23 | import org.apache.commons.logging.Log; |
| 24 | import org.apache.commons.logging.LogFactory; |
| 25 | import org.jdtaus.core.container.ContainerFactory; |
| 26 | import org.jdtaus.core.logging.spi.Logger; |
| 27 | |
| 28 | /** |
| 29 | * jDTAUS Core SPI Commons Logging {@code Logger} implementation. |
| 30 | * <p>The name of the commons logger is specified by property {@code name}. |
| 31 | * Property {@code name} defaults to {@code org.jdtaus.runtime}.</p> |
| 32 | * |
| 33 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
| 34 | * @version $JDTAUS: CommonsLoggingLogger.java 8743 2012-10-07 03:06:20Z schulte $ |
| 35 | * |
| 36 | * @see org.jdtaus.core.container.Container |
| 37 | */ |
| 38 | public class CommonsLoggingLogger implements Logger |
| 39 | { |
| 40 | //--Constructors------------------------------------------------------------ |
| 41 | |
| 42 | // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausConstructors |
| 43 | // This section is managed by jdtaus-container-mojo. |
| 44 | |
| 45 | /** Standard implementation constructor <code>org.jdtaus.core.logging.ri.commons.CommonsLoggingLogger</code>. */ |
| 46 | public CommonsLoggingLogger() |
| 47 | { |
| 48 | super(); |
| 49 | } |
| 50 | |
| 51 | // </editor-fold>//GEN-END:jdtausConstructors |
| 52 | |
| 53 | //------------------------------------------------------------Constructors-- |
| 54 | //--Properties-------------------------------------------------------------- |
| 55 | |
| 56 | // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausProperties |
| 57 | // This section is managed by jdtaus-container-mojo. |
| 58 | |
| 59 | /** |
| 60 | * Gets the value of property <code>name</code>. |
| 61 | * |
| 62 | * @return Name uniquely identifying the logger. |
| 63 | */ |
| 64 | public java.lang.String getName() |
| 65 | { |
| 66 | return (java.lang.String) ContainerFactory.getContainer(). |
| 67 | getProperty( this, "name" ); |
| 68 | |
| 69 | } |
| 70 | |
| 71 | // </editor-fold>//GEN-END:jdtausProperties |
| 72 | |
| 73 | //--------------------------------------------------------------Properties-- |
| 74 | //--Logger------------------------------------------------------------------ |
| 75 | |
| 76 | public boolean isDebugEnabled() |
| 77 | { |
| 78 | return this.getLogger().isDebugEnabled(); |
| 79 | } |
| 80 | |
| 81 | public void debug( final String message ) |
| 82 | { |
| 83 | this.getLogger().debug( message ); |
| 84 | } |
| 85 | |
| 86 | public void debug( final Throwable throwable ) |
| 87 | { |
| 88 | this.getLogger().debug( throwable.getMessage(), throwable ); |
| 89 | } |
| 90 | |
| 91 | public boolean isErrorEnabled() |
| 92 | { |
| 93 | return this.getLogger().isErrorEnabled(); |
| 94 | } |
| 95 | |
| 96 | public void error( final String message ) |
| 97 | { |
| 98 | this.getLogger().error( message ); |
| 99 | } |
| 100 | |
| 101 | public void error( final 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( final String message ) |
| 112 | { |
| 113 | this.getLogger().fatal( message ); |
| 114 | } |
| 115 | |
| 116 | public void fatal( final 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( final String message ) |
| 127 | { |
| 128 | this.getLogger().info( message ); |
| 129 | } |
| 130 | |
| 131 | public void info( final 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( final String message ) |
| 142 | { |
| 143 | this.getLogger().trace( message ); |
| 144 | } |
| 145 | |
| 146 | public void trace( final 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( final String message ) |
| 157 | { |
| 158 | this.getLogger().warn( message ); |
| 159 | } |
| 160 | |
| 161 | public void warn( final 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 | } |