Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Trace Method Execution

Kay-Uwe Janssen edited this page Oct 9, 2016 · 8 revisions

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.

You must enable tracing in the processing options, otherwise tracing code will not be generated!

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

Customization

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

Using AndroidAnnotations

Questions?

Enjoying AndroidAnnotations

Improving AndroidAnnotations

Extending AndroidAnnotations

Clone this wiki locally