From: mwebster Date: Fri, 25 Aug 2006 11:31:30 +0000 (+0000) Subject: Bug 150487 "Tracing and Logging Framework" (Trace.event()) X-Git-Tag: BEFORE_133532~74 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5787d0e82f32648f30f4677c13aef68d4615e300;p=aspectj.git Bug 150487 "Tracing and Logging Framework" (Trace.event()) --- diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 7e2edb5c0..45fb96d8a 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -186,6 +186,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { } String resourcePath = System.getProperty("org.aspectj.weaver.loadtime.configuration",AOP_XML); + trace.event("parseDefinitions",this,resourcePath); StringTokenizer st = new StringTokenizer(resourcePath,";"); while(st.hasMoreTokens()){ diff --git a/weaver/src/org/aspectj/weaver/tools/AbstractTrace.java b/weaver/src/org/aspectj/weaver/tools/AbstractTrace.java index 893650b1f..23d2aba39 100644 --- a/weaver/src/org/aspectj/weaver/tools/AbstractTrace.java +++ b/weaver/src/org/aspectj/weaver/tools/AbstractTrace.java @@ -34,14 +34,6 @@ public abstract class AbstractTrace implements Trace { public abstract void exit(String methodName, Throwable th); - public void event(String methodName) { - throw new UnsupportedOperationException("event"); - } - - public void event(String methodName, Object thiz, Object[] args) { - throw new UnsupportedOperationException("event"); - } - /* * Convenience methods */ @@ -61,6 +53,10 @@ public abstract class AbstractTrace implements Trace { exit(methodName,new Boolean(b)); } + public void event (String methodName, Object thiz, Object arg) { + event(methodName,thiz,new Object[] { arg }); + } + public void warn(String message) { warn(message,null); } diff --git a/weaver/src/org/aspectj/weaver/tools/CommonsTrace.java b/weaver/src/org/aspectj/weaver/tools/CommonsTrace.java index 75afbaf2d..25562c050 100644 --- a/weaver/src/org/aspectj/weaver/tools/CommonsTrace.java +++ b/weaver/src/org/aspectj/weaver/tools/CommonsTrace.java @@ -54,6 +54,18 @@ public class CommonsTrace extends AbstractTrace { } } + public void event(String methodName, Object thiz, Object[] args) { + if (log.isDebugEnabled()) { + log.debug(formatMessage("-", className, methodName, thiz, args)); + } + } + + public void event(String methodName) { + if (log.isDebugEnabled()) { + log.debug(formatMessage("-", className, methodName, null, null)); + } + } + public boolean isTraceEnabled () { return log.isDebugEnabled(); } diff --git a/weaver/src/org/aspectj/weaver/tools/DefaultTrace.java b/weaver/src/org/aspectj/weaver/tools/DefaultTrace.java index ddb03dbb5..788bc95eb 100644 --- a/weaver/src/org/aspectj/weaver/tools/DefaultTrace.java +++ b/weaver/src/org/aspectj/weaver/tools/DefaultTrace.java @@ -55,6 +55,19 @@ public class DefaultTrace extends AbstractTrace { println(formatMessage("<",tracedClass.getName(),methodName,th, null)); } } + + public void event(String methodName, Object thiz, Object[] args) { + if (traceEnabled) { + println(formatMessage("-",tracedClass.getName(),methodName,thiz, args)); + } + } + + public void event(String methodName) { + if (traceEnabled) { + println(formatMessage("-",tracedClass.getName(),methodName,null,null)); + } + } + public void debug (String message) { println(formatMessage("?",message,null)); } diff --git a/weaver/src/org/aspectj/weaver/tools/Trace.java b/weaver/src/org/aspectj/weaver/tools/Trace.java index ace5f4971..6c4ac3873 100644 --- a/weaver/src/org/aspectj/weaver/tools/Trace.java +++ b/weaver/src/org/aspectj/weaver/tools/Trace.java @@ -51,6 +51,8 @@ public interface Trace { public void enter (String methodName, Object thiz, boolean z); public void exit (String methodName, boolean b); + + public void event (String methodName, Object thiz, Object arg); public boolean isTraceEnabled (); diff --git a/weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java b/weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java index b28323a91..8f895a81b 100644 --- a/weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java +++ b/weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java @@ -73,6 +73,18 @@ public abstract class AbstractTraceTest extends TestCase { trace.exit("testExit"); } + public void testEvent() { + trace.event("testEvent"); + } + + public void testEventWithThisAndArgs() { + trace.event("testEventWithThisAndArgs",this,new Object[] { "arg1", "arg2" }); + } + + public void testEventWithThisAndArg() { + trace.event("testEventWithThisAndArg",this,"arg1"); + } + public void testDebug() { trace.debug("debug"); } diff --git a/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java b/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java index ffb49939e..28c46d4ea 100644 --- a/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java +++ b/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java @@ -56,6 +56,21 @@ public class Jdk14Trace extends AbstractTrace { } } + public void event(String methodName, Object thiz, Object[] args) { + if (logger.isLoggable(Level.FINE)) { + logger.logp(Level.FINER,name,methodName,"EVENT",formatObj(thiz)); + if (args != null && logger.isLoggable(Level.FINER)) { + logger.logp(Level.FINER,name,methodName,"EVENT",args); + } + } + } + + public void event(String methodName) { + if (logger.isLoggable(Level.FINE)) { + logger.logp(Level.FINER,name,methodName,"EVENT"); + } + } + public boolean isTraceEnabled() { return logger.isLoggable(Level.FINER); }