Modify "log" command to show stack trace. (FELIX-1987)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@907001 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/shell/src/main/java/org/apache/felix/shell/impl/LogCommandImpl.java b/shell/src/main/java/org/apache/felix/shell/impl/LogCommandImpl.java
index 21f7931..089ff5c 100644
--- a/shell/src/main/java/org/apache/felix/shell/impl/LogCommandImpl.java
+++ b/shell/src/main/java/org/apache/felix/shell/impl/LogCommandImpl.java
@@ -19,6 +19,8 @@
 package org.apache.felix.shell.impl;
 
 import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Enumeration;
@@ -77,16 +79,20 @@
         StringBuffer buffer = new StringBuffer();
         buffer.append(sdf.format(new Date(entry.getTime()))).append(" ");
         buffer.append(levelAsAString(entry.getLevel())).append(" - ");
-        buffer.append("Bundle:").append(entry.getBundle().getSymbolicName()).append(" ");
+        buffer.append("Bundle: ").append(entry.getBundle().getSymbolicName());
         if (entry.getServiceReference() != null)
         {
-            buffer.append(entry.getServiceReference().toString()).append(" ");
+            buffer.append(" - ");
+            buffer.append(entry.getServiceReference().toString());
         }
-        buffer.append("- ").append(entry.getMessage()).append(" - ");
+        buffer.append(" - ").append(entry.getMessage());
         if (entry.getException() != null)
         {
-            buffer.append(entry.getException().getClass().getName()).append(": ").append(
-                entry.getException().getMessage());
+            buffer.append(" - ");
+            StringWriter writer = new StringWriter();
+            PrintWriter  pw = new PrintWriter(writer);
+            entry.getException().printStackTrace(pw);
+            buffer.append(writer.toString());
         }
 
         out.println(buffer.toString());