19package org.openoffice.xmerge.util;
21import java.io.BufferedWriter;
22import java.io.IOException;
23import java.io.FileWriter;
24import java.io.InputStream;
25import java.io.OutputStream;
26import java.io.OutputStreamWriter;
27import java.io.PrintWriter;
29import java.util.Properties;
42 public static final int INFO = 0x0001;
44 public static final int ERROR = 0x0002;
46 public static final int TRACE = 0x0004;
49 private static final boolean SET =
true;
52 private static PrintWriter
writer =
null;
56 InputStream is =
null;
59 is =
Debug.class.getResourceAsStream(
"Debug.properties");
63 String info =
props.getProperty(
"debug.info",
"false");
64 info = info.toLowerCase();
66 if (info.equals(
"true")) {
70 String trace =
props.getProperty(
"debug.trace",
"false");
71 trace = trace.toLowerCase();
73 if (trace.equals(
"true")) {
77 String error =
props.getProperty(
"debug.error",
"false");
78 error = error.toLowerCase();
80 if (error.equals(
"true")) {
84 String w =
props.getProperty(
"debug.output",
"System.out");
91 }
catch (Throwable
ex) {
114 if (str.equals(
"System.out")) {
116 }
else if (str.equals(
"System.err")) {
121 }
catch (IOException e) {
122 e.printStackTrace(
System.err);
146 writer =
new PrintWriter(
new BufferedWriter(
w),
true);
177 return ((
flags & f) != 0);
205 public static void log(
int flag, String msg) {
223 public static void log(
int flag, String msg, Throwable e) {
227 e.printStackTrace(
writer);
This class is used for logging debug messages.
static final int INFO
Informational messages.
static PrintWriter writer
static final boolean SET
To set a flag.
static void setOutput(Writer w)
Set the Writer object to manage the output.
static boolean isFlagSet(int f)
Checks if flag is set.
static final int TRACE
Trace messages.
Debug()
Private constructor so as not to allow any instances of this class.
static void setOutput(OutputStream stream)
Set the output to an OutputStream object.
static void setFlags(int f, boolean set)
This method sets the levels for debugging logs.
static void setOutput(String str)
Set the output to the specified argument.
static void log(int flag, String msg, Throwable e)
Log message based on flag type plus print out stack trace of the exception passed in.
static void log(int flag, String msg)
Log message based on the flag type.
static final int ERROR
Error messages.
Reference< XOutputStream > stream