]> source.dussan.org Git - aspectj.git/commitdiff
Bug 150487 "Tracing and Logging Framework" (Trace.event())
authormwebster <mwebster>
Fri, 25 Aug 2006 11:31:30 +0000 (11:31 +0000)
committermwebster <mwebster>
Fri, 25 Aug 2006 11:31:30 +0000 (11:31 +0000)
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
weaver/src/org/aspectj/weaver/tools/AbstractTrace.java
weaver/src/org/aspectj/weaver/tools/CommonsTrace.java
weaver/src/org/aspectj/weaver/tools/DefaultTrace.java
weaver/src/org/aspectj/weaver/tools/Trace.java
weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java
weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java

index 7e2edb5c00625c48f277171dcfccb8c3e3643762..45fb96d8ae74330a98fb35ce3c3de50b4b3c9e36 100644 (file)
@@ -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()){
index 893650b1f9da84fcc72a3d03710da4f3808999e5..23d2aba39ddce121a3dcd6ae959f1196f93306c3 100644 (file)
@@ -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);
        }
index 75afbaf2d26c2a80edfe63d4b7e222267d70eaab..25562c0506a1fbd9aa780b0e70e2d88ce90ae821 100644 (file)
@@ -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();
        }
index ddb03dbb5cca26e5dd7440d592ddfad7f44196c6..788bc95eb3d7c52f9d6bb5fc0e8d32d2a7f5be6e 100644 (file)
@@ -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));
        }
index ace5f49716feb57e726cafc45820ffe0de8aeb11..6c4ac387306db883ff7817b1243466d1996ce0ea 100644 (file)
@@ -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 ();
 
index b28323a91fba3aded5da7ed625e4b426bc6f2430..8f895a81b41d13a1ad7f1d03ff4b902a45cf67ff 100644 (file)
@@ -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");
        }
index ffb49939e1fbbc0acdb85e9335f1fa9f069927f3..28c46d4eadf4b9a722de144c0fbb7e15105707b5 100644 (file)
@@ -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);
        }