@Loggable manual
You're in a situation when you must produce a log when a method (or some methods) are invoked. How can you implement this? AnnoJ can help you.
If all methods in a class must be logged simply annotate that class with annotation
@Loggable:
@Loggable
public class ClassToLog{
//many important methods
}
If the class is loaded by
TransformingCassLoader then all method invocations (including provate methods) i the class will be logged. Logging uses the
java.util.logging.Logger class and every invocation is logged on info level.
If you only have to log a few mwthods you have two choices. First, you can annotate the methods eith annotation
@Loggable:
public class ClassToLog{
@Loggable
public void importantMethod(){
}
//less important methods
}
In this case only
importantMethod will be logged. If the both the class and the method are annotated then the class level annotation wins: all method will be logged.
Your second choice is to list the method names to log in the
@Loggable method parameter:
@Loggable(methods={"importantMehtod"})
public class ClassToLog{
public void importantMehtod(){
}
//and the others
}
If you want all methods of classes in a package be logged you have to define a class named
PackageInfo in that package and annotate it with
@Loggable:
@Loggable
public class PackageInfo{}