directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcon...@apache.org
Subject svn commit: r487265 - /directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/LogServiceImpl.java
Date Thu, 14 Dec 2006 17:24:03 GMT
Author: jconlon
Date: Thu Dec 14 09:24:03 2006
New Revision: 487265

URL: http://svn.apache.org/viewvc?view=rev&rev=487265
Log:
Check for null arguments

Modified:
    directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/LogServiceImpl.java

Modified: directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/LogServiceImpl.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/LogServiceImpl.java?view=diff&rev=487265&r1=487264&r2=487265
==============================================================================
--- directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/LogServiceImpl.java
(original)
+++ directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/LogServiceImpl.java
Thu Dec 14 09:24:03 2006
@@ -116,22 +116,29 @@
      */
     public void log( ServiceReference sr, int level, String message )
     {
+        StringBuffer output = new StringBuffer();
+        if(sr!=null){
+           output.append('[').append( sr.getBundle().getBundleId()).append( ']').append(message);

+        }else{
+            output.append( "[Unknown]").append( message);
+        }
+
         switch (level) {
         case LOG_DEBUG:
-            delegate.debug( '[' + sr.getBundle().getBundleId() + ']' + message );
+            delegate.debug(output.toString() );
             break;
         case LOG_ERROR:
-            delegate.error( '[' + sr.getBundle().getBundleId() + ']' + message );
+            delegate.error( output.toString() );
             break;
         case LOG_INFO:
-            delegate.info( '[' + sr.getBundle().getBundleId() + ']' + message );
+            delegate.info( output.toString() );
             break;
         case LOG_WARNING:
-            delegate.warn( '[' + sr.getBundle().getBundleId() + ']' + message );
+            delegate.warn( output.toString() );
             break;
         default:
             break;
-        }
+      }
     }
 
     /**
@@ -157,22 +164,29 @@
      */
     public void log( ServiceReference sr, int level, String message, Throwable exception
)
     {
+        StringBuffer output = new StringBuffer();
+        if(sr!=null){
+           output.append('[').append( sr.getBundle().getBundleId()).append( ']').append(message);

+        }else{
+            output.append( "[Unknown]").append( message);
+        }
+
         switch (level) {
         case LOG_DEBUG:
-            delegate.debug( '[' + sr.getBundle().getBundleId() + ']' + message, exception
);
+            delegate.debug(output.toString(), exception );
             break;
         case LOG_ERROR:
-            delegate.error( '[' + sr.getBundle().getBundleId() + ']' + message, exception
);
+            delegate.error( output.toString(), exception );
             break;
         case LOG_INFO:
-            delegate.info( '[' + sr.getBundle().getBundleId() + ']' + message, exception
);
+            delegate.info( output.toString(), exception );
             break;
         case LOG_WARNING:
-            delegate.warn( '[' + sr.getBundle().getBundleId() + ']' + message, exception
);
+            delegate.warn( output.toString(), exception );
             break;
         default:
             break;
-        }
+      }
     }
 
 }



Mime
View raw message