001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/framework/log/JBossLogger.java $
002 /*---------------- FILE HEADER ------------------------------------------
003
004 This file is part of deegree.
005 Copyright (C) 2001-2006 by:
006 EXSE, Department of Geography, University of Bonn
007 http://www.giub.uni-bonn.de/deegree/
008 lat/lon GmbH
009 http://www.lat-lon.de
010
011 This library is free software; you can redistribute it and/or
012 modify it under the terms of the GNU Lesser General Public
013 License as published by the Free Software Foundation; either
014 version 2.1 of the License, or (at your option) any later version.
015
016 This library is distributed in the hope that it will be useful,
017 but WITHOUT ANY WARRANTY; without even the implied warranty of
018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019 Lesser General Public License for more details.
020
021 You should have received a copy of the GNU Lesser General Public
022 License along with this library; if not, write to the Free Software
023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024
025 Contact:
026
027 Andreas Poth
028 lat/lon GmbH
029 Aennchenstr. 19
030 53115 Bonn
031 Germany
032 E-Mail: poth@lat-lon.de
033
034 Prof. Dr. Klaus Greve
035 Department of Geography
036 University of Bonn
037 Meckenheimer Allee 166
038 53115 Bonn
039 Germany
040 E-Mail: greve@giub.uni-bonn.de
041
042
043 ---------------------------------------------------------------------------*/
044 package org.deegree.framework.log;
045
046 /**
047 * Log service provided for JBoss log service.
048 * To configure the log system use the JBoss log configuration file.
049 *
050 * @author <a href="mailto:tfr@users.sourceforge.net">Torsten Friebe </A>
051 *
052 * @author last edited by: $Author: bezema $
053 *
054 * @version 2.0, $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $
055 *
056 * @see <a href="http://www.jboss.org/developers/guides/logging">JBoss logging
057 * </a>
058 *
059 * @since 2.0
060 */
061 final class JBossLogger extends LoggerService {
062
063 private org.jboss.logging.Logger log;
064
065 /**
066 * Factory method to retrieve the instance of the Server.
067 *
068 * @returns an instance of LogServer
069 */
070 JBossLogger() {
071 super();
072 }
073
074 public void bindClass(String name) {
075 this.log = org.jboss.logging.Logger.getLogger(name);
076 }
077
078 public void bindClass(Class name) {
079 this.log = org.jboss.logging.Logger.getLogger(name);
080 }
081
082 public void logError(String message) {
083 this.log.error(message);
084 }
085
086 public void logError(String message, Throwable ex) {
087 this.log.error(message, ex);
088 }
089
090 @Override
091 public void logWarning(String message) {
092 this.log.warn(message);
093 }
094
095 @Override
096 public void logWarning(String message, Throwable ex) {
097 this.log.warn(message, ex);
098 }
099
100 @Override
101 public void logInfo(String message) {
102 if (this.log.isInfoEnabled()) {
103 this.log.info(message);
104 }
105 }
106
107 @Override
108 public void logInfo(String message, Throwable ex) {
109 if (this.log.isInfoEnabled()) {
110 this.log.info(message, ex);
111 }
112 }
113
114 public void logInfo(String message, Object tracableObject) {
115 if (this.log.isInfoEnabled()) {
116 this.log.info(message + tracableObject);
117 }
118 }
119
120 @Override
121 public void logDebug(String message) {
122 if (this.log.isDebugEnabled()) {
123 this.log.debug(message);
124 }
125 }
126
127 @Override
128 public void logDebug(String message, Throwable ex) {
129 if (this.log.isDebugEnabled()) {
130 this.log.debug(message, ex);
131 }
132 }
133
134 public void logDebug(String message, Object tracableObject) {
135 if (this.log.isDebugEnabled()) {
136 this.log.debug(message + tracableObject);
137 }
138 }
139
140 public void log(int priority, String message, Throwable ex) {
141 this.logDebug(message, ex);
142 }
143
144 public void log(int priority, String message, Object source, Throwable ex) {
145 this.logDebug(message + source.toString(), ex);
146 }
147
148 /*
149 * (non-Javadoc)
150 *
151 * @see org.deegree_framework.log.ILogger#getLevel()
152 */
153 public int getLevel() {
154 int logLevel;
155 if (this.log.isDebugEnabled()) {
156 logLevel = LOG_DEBUG;
157 } else if (this.log.isInfoEnabled()) {
158 logLevel = LOG_INFO;
159 } else if (this.log.isTraceEnabled()) {
160 logLevel = LOG_DEBUG;
161 } else {
162 logLevel = LOG_WARNING;
163 }
164 return logLevel;
165 }
166
167 /**
168 * Set the log level.
169 *
170 * @see org.deegree.framework.log.ILogger#setLevel(int)
171 * @BUG Currently not supported by JBoss Logging.
172 */
173 public void setLevel(int level) {
174 // not supported API
175 }
176
177 public boolean isDebug() {
178 return log.isDebugEnabled();
179 }
180
181 @Override
182 public String toString() {
183 return ("Logging Class: " + this.log.getClass().getName());
184 }
185 }
186
187 /*
188 * *****************************************************************************
189 * Changes to this class. What the people have been up to: $Log:
190 * JBossLogger.java,v $ Revision 1.2 2004/06/15 14:58:19 tf refactored Logger
191 * and add new methods
192 *
193 * Revision 1.1 2004/05/14 15:26:38 tf initial checkin
194 *
195 *
196 * ***************************************************************************
197 */
198