[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Question on Tracing Aspect
|
Manjula,
Please see my append to aspectj-dev for a good tracing aspect example:
http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01261.html. If you want
per-thread tracing i.e. one logger per thread instead of the usual one
logger per class you will need to make your Logger a ThreadLocal. Only do
this if you want to control tracing on a per-thread basis because most
implementations allow you to distinguish outputs produced on different
threads.
Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester, SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/
Manjula Jayaraman <manjuv123@xxxxxxxxx>@eclipse.org on 03/05/2005 23:27:04
Please respond to aspectj-users@xxxxxxxxxxx
Sent by: aspectj-users-bounces@xxxxxxxxxxx
To: aspectj-users@xxxxxxxxxxx
cc:
Subject: [aspectj-users] Question on Tracing Aspect
Hi All,
I'm new to Aspect J. I wrote my first aspect using
Aspect J for tracing. I would like to log a message
upon entry and exit of all the methods in ALL the
packages in my project.
I've a class called EspressoLog as follows:
public class EspressoTrace {
private static Logger logger = null;
public static void initLogger(Logger l) {
logger = l;
}
public static void traceEntry(String message)
{
logger.debug("Entering : " + message);
}
public static void traceExit(String message) {
logger.debug("Exiting : " + message);
}
}
I've another class as follows
aspect EspressoTraceAspect {
private Logger logger;
pointcut traceCall() : target(*) &&
execution(public *
com.apple.ist.espresso.xmlparser..*(..));
before() : traceCall() {
EspressoTrace.initLogger(EspressoLogger.getLogger(thisJoinPointStaticPart.getSignature().getName().getClass()));
EspressoTrace.traceEntry("" +
thisJoinPointStaticPart.getSignature().getName());
}
after() : traceCall() {
EspressoTrace.traceExit("" +
thisJoinPointStaticPart.getSignature().getName());
}
}
My problem is that i'm calling initLogger every time
in before method of my EspressoTraceAspect. But the
efficient way to do this is to call only once per
invocation of a class not before the invocation of
each method in that class. how can i achieve this?
Also, if the same class is called through multiple
threads having the Logger attribute as static in
EspressoTraceAspect would not help. How should i
handle that?
Thanks for any input in advance,
Manjula
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users