summaryrefslogtreecommitdiff
path: root/scripting/java/com/sun/star/script/framework/log/LogUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'scripting/java/com/sun/star/script/framework/log/LogUtils.java')
-rw-r--r--scripting/java/com/sun/star/script/framework/log/LogUtils.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/scripting/java/com/sun/star/script/framework/log/LogUtils.java b/scripting/java/com/sun/star/script/framework/log/LogUtils.java
new file mode 100644
index 000000000000..ef4b1f9a56ec
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/log/LogUtils.java
@@ -0,0 +1,68 @@
+package com.sun.star.script.framework.log;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+public class LogUtils {
+
+ private static boolean m_bDebugEnabled = false;
+
+ static
+ {
+ String debugFlag =
+ System.getProperties().getProperty("ScriptJavaRuntimeDebug");
+
+ if (debugFlag != null && debugFlag.length() > 0)
+ {
+ m_bDebugEnabled = debugFlag.equalsIgnoreCase("true");
+ }
+ }
+
+ // Ensure that instances of this class cannot be created
+ private LogUtils() {
+ }
+
+ /**
+ * Print Debug Output
+ *
+ * @param msg message to be displayed
+ */
+ public static void DEBUG(String msg)
+ {
+ if (m_bDebugEnabled)
+ {
+ System.out.println(msg);
+ }
+ }
+
+ public static String getTrace( Exception e )
+ {
+ ByteArrayOutputStream baos = null;
+ PrintStream ps = null;
+ String result = "";
+ try
+ {
+ baos = new ByteArrayOutputStream( );
+ ps = new PrintStream( baos );
+ e.printStackTrace( ps );
+ }
+ finally
+ {
+ try
+ {
+ if ( baos != null )
+ {
+ baos.close();
+ }
+ if ( ps != null )
+ {
+ ps.close();
+ }
+ }
+ catch ( Exception excp )
+ {
+ }
+ }
+ return result;
+ }
+}