[slf4j-dev] svn commit: r721 - slf4j/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl

jconlon at slf4j.org jconlon at slf4j.org
Fri Feb 9 16:52:29 CET 2007


Author: jconlon
Date: Fri Feb  9 16:52:28 2007
New Revision: 721

Modified:
   slf4j/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java

Log:
Check log level before creating strings.

Modified: slf4j/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java
==============================================================================
--- slf4j/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java	(original)
+++ slf4j/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java	Fri Feb  9 16:52:28 2007
@@ -120,20 +120,27 @@
 	 *      int, java.lang.String)
 	 */
 	public void log(ServiceReference sr, int level, String message) {
-		String output = createMessage(sr, message);
-
+		
 		switch (level) {
 		case LOG_DEBUG:
-			delegate.debug(output);
+			if(delegate.isDebugEnabled()){
+				delegate.debug(createMessage(sr, message));
+			}
 			break;
 		case LOG_ERROR:
-			delegate.error(output);
+			if(delegate.isErrorEnabled()){
+				delegate.error(createMessage(sr, message));
+			}
 			break;
 		case LOG_INFO:
-			delegate.info(output);
+			if(delegate.isInfoEnabled()){
+				delegate.info(createMessage(sr, message));
+			}
 			break;
 		case LOG_WARNING:
-			delegate.warn(output);
+			if(delegate.isWarnEnabled()){
+				delegate.warn(createMessage(sr, message));
+			}
 			break;
 		default:
 			break;
@@ -166,20 +173,27 @@
 	 */
 	public void log(ServiceReference sr, int level, String message,
 			Throwable exception) {
-		String output = createMessage(sr, message);
 
 		switch (level) {
 		case LOG_DEBUG:
-			delegate.debug(output, exception);
+			if(delegate.isDebugEnabled()){
+				delegate.debug(createMessage(sr, message), exception);
+			}
 			break;
 		case LOG_ERROR:
-			delegate.error(output, exception);
+			if(delegate.isErrorEnabled()){
+				delegate.error(createMessage(sr, message), exception);
+			}
 			break;
 		case LOG_INFO:
-			delegate.info(output, exception);
+			if(delegate.isInfoEnabled()){
+				delegate.info(createMessage(sr, message), exception);
+			}
 			break;
 		case LOG_WARNING:
-			delegate.warn(output, exception);
+			if(delegate.isWarnEnabled()){
+				delegate.warn(createMessage(sr, message), exception);
+			}
 			break;
 		default:
 			break;



More information about the slf4j-dev mailing list