1 /*
2 * jDTAUS Core RI Slf4J Logging
3 * Copyright (C) 2005 Christian Schulte <cs@schulte.it>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * $JDTAUS: Slf4JLogger.java 8641 2012-09-27 06:45:17Z schulte $
20 */
21 package org.jdtaus.core.logging.ri.slf4j;
22
23 import org.jdtaus.core.container.ContainerFactory;
24 import org.jdtaus.core.logging.spi.Logger;
25
26 /**
27 * jDTAUS Core SPI Slf4J {@code Logger} implementation.
28 * <p>The name of the Slf4J logger is specified by property {@code name}.
29 * Property {@code name} defaults to {@code org.jdtaus.runtime}.</p>
30 *
31 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
32 * @version $JDTAUS: Slf4JLogger.java 8641 2012-09-27 06:45:17Z schulte $
33 */
34 public class Slf4JLogger implements Logger
35 {
36 //--Logger------------------------------------------------------------------
37
38 public boolean isDebugEnabled()
39 {
40 return this.getLogger().isDebugEnabled();
41 }
42
43 public void debug( final String message )
44 {
45 this.getLogger().debug( message );
46 }
47
48 public void debug( final Throwable t )
49 {
50 this.getLogger().debug( t.getMessage(), t );
51 }
52
53 public boolean isErrorEnabled()
54 {
55 return this.getLogger().isErrorEnabled();
56 }
57
58 public void error( final String message )
59 {
60 this.getLogger().error( message );
61 }
62
63 public void error( final Throwable t )
64 {
65 this.getLogger().error( t.getMessage(), t );
66 }
67
68 public boolean isFatalEnabled()
69 {
70 return this.isErrorEnabled();
71 }
72
73 public void fatal( final String message )
74 {
75 this.error( message );
76 }
77
78 public void fatal( final Throwable t )
79 {
80 this.error( t );
81 }
82
83 public boolean isInfoEnabled()
84 {
85 return this.getLogger().isInfoEnabled();
86 }
87
88 public void info( final String message )
89 {
90 this.getLogger().info( message );
91 }
92
93 public void info( final Throwable t )
94 {
95 this.getLogger().info( t.getMessage(), t );
96 }
97
98 public boolean isTraceEnabled()
99 {
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 }