}
}
public void debug (String message) {
- if (traceEnabled) {
- println(formatMessage("?",message,null));
- }
+ println(formatMessage("?",message,null));
}
public void info(String message) {
- if (traceEnabled) {
- println(formatMessage("I",message,null));
- }
+ println(formatMessage("I",message,null));
}
public void warn (String message, Throwable th) {
- if (traceEnabled) {
- println(formatMessage("W",message,th));
- if (th != null) th.printStackTrace();
- }
+ println(formatMessage("W",message,th));
+ if (th != null) th.printStackTrace();
}
public void error (String message, Throwable th) {
- if (traceEnabled) {
- println(formatMessage("E",message,th));
- if (th != null) th.printStackTrace();
- }
-
+ println(formatMessage("E",message,th));
+ if (th != null) th.printStackTrace();
}
public void fatal (String message, Throwable th) {
- if (traceEnabled) {
- println(formatMessage("X",message,th));
- if (th != null) th.printStackTrace();
- }
+ println(formatMessage("X",message,th));
+ if (th != null) th.printStackTrace();
}
/**
public final static String DEBUG_PROPERTY = "org.aspectj.tracing.debug";
public final static String FACTORY_PROPERTY = "org.aspectj.tracing.factory";
+ public final static String DEFAULT_FACTORY_NAME = "default";
private static boolean debug = getBoolean(DEBUG_PROPERTY,false);
- private static TraceFactory instance = new DefaultTraceFactory();
+ private static TraceFactory instance;
public Trace getTrace (Class clazz) {
return instance.getTrace(clazz);
}
static {
- try {
+
+ /*
+ * Allow user to override default behaviour or specify their own factory
+ */
+ String factoryName = System.getProperty(FACTORY_PROPERTY);
+ if (factoryName != null) try {
+ if (factoryName.equals(DEFAULT_FACTORY_NAME)) {
+ instance = new DefaultTraceFactory();
+ }
+ else {
+ Class factoryClass = Class.forName(factoryName);
+ instance = (TraceFactory)factoryClass.newInstance();
+ }
+ }
+ catch (Throwable th) {
+ if (debug) th.printStackTrace();
+ }
+
+ /*
+ * Try to load external trace infrastructure using supplied factories
+ */
+ if (instance == null) try {
if (LangUtil.is15VMOrGreater()) {
Class factoryClass = Class.forName("org.aspectj.weaver.tools.Jdk14TraceFactory");
instance = (TraceFactory)factoryClass.newInstance();
catch (Throwable th) {
if (debug) th.printStackTrace();
}
+
+ /*
+ * Use default trace
+ */
+ if (instance == null) {
+ instance = new DefaultTraceFactory();
+ }
if (debug) System.out.println("TraceFactory.instance=" + instance);
}