-
Notifications
You must be signed in to change notification settings - Fork 0
Trace Method Execution
Since AndroidAnnotations 2.2
The @Trace annotation allows you to trace the execution of a method by writing log entries.
The method must not be private.
Usage examples:
@Trace
void doWork() {
// ... Do Work ...
}
@Trace
boolean doMoreWork(String someString) {
// ... Do more Work ...
}Will generate the following log entries for doWork():
I/TracedMethodActivity( 302): Entering [void doWork() ]
I/TracedMethodActivity( 302): Exiting [void doWork() ], duration in ms: 1002
And this log entries for doMoreWork():
Since AndroidAnnotations 3.1
I/TracedMethodActivity( 302): Entering [boolean doMoreWork(someString = Hello World)]
I/TracedMethodActivity( 302): Exiting [boolean doMoreWork(String) returning: true], duration in ms: 651
Since AndroidAnnotations 2.2 You can also specify the tag and the level of the log message:
@Trace(tag="CustomTag", level=Log.WARN)
void doWork() {
// ... Do Work ...
}W/CustomTag( 533): Entering [void doWork() ]
W/CustomTag( 533): Exiting [void doWork() ], duration in ms: 1001
You can disable @Trace related code at compile by passing an option to the annotation processor when javac is invoked :
javac -Atrace=false ...
It can also be added in Eclipse as an annotation processor parameter, in Project Properties > Java Compiler > Annotation Processing > Processor options > New with key trace and value false.
You can read more information here about how to customize annotation processing in other IDEs and build tools.
AndroidAnnotations was created by Pierre-Yves Ricau and is sponsored by eBusinessInformations.
09/11/2014 The 3.2 release is out !
- Get started!
- Download
- Cookbook, full of recipes
- Customize annotation processing
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow