Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Logging enabled check idea

Would this do the trick ?
It will for sure hit regarding to the pointcut, but not quite shure if
it will actually save the construction of the string.

@Aspect
public class LoggingAspect {
   @Around("call (* Logger.debug(..)) && target(log) &&
!within(LoggingAspect)")
   public void isDebugEnabled(ProceedingJoinPoint thisJoinPoint,
Logger log) throws Throwable {
       if (log.isDebugEnabled()) {
           thisJoinPoint.proceed();
       }
   }
}

/Kaare Nilsen

On 06/06/06, Wim Deblauwe <wim.deblauwe@xxxxxxxxx> wrote:
Hi,

I just had this idea for the use of aspectj, but I don't know if it is
possible:

Most of you know that they can check if logging is enabled before putting
the log statement in their code, however, very few do this because it
clutters the code. Would it be possible to define an aspect that adds all
those checks in there (with log4j and/or commons-logging)?

Just an idea if someone has some time to spare :)

regards,

Wim

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users





Back to the top