JakeWharton / hugo

Annotation-triggered method call logging for your debug builds.
Apache License 2.0
7.92k stars 797 forks source link

Add support for Trace.beginSection/endSection #83

Closed yogurtearl closed 8 years ago

yogurtearl commented 9 years ago

Not sure if this is in the scope of Hugo, but have an annotation for wrapping methods in Trace.beginSection/endSection would be very helpful.

Maybe a parameter to @DebugLog? @DebugLog(trace=true) Maybe a separate annotation ( @DebugTrace ) ?

output would function like:

class Bar{
  void foo(int snarg){
     if( SDK_INT >= 18 ){
            Trace.beginSection("Bar.foo(snarg="+ snarg+")")); 
      }
      try {
             <method_body>
      } finally {
         if( SDK_INT >= 18 ){
             Trace.endSection();
         }
      }
  }

}
JakeWharton commented 9 years ago

What about always doing it for annotated methods? Too much?

yogurtearl commented 9 years ago

From a quick glance at the code, it looks like Trace is low overhead when you are not actively tracing: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/os/Trace.java

So always-on Trace'ing for @DebugLog might be OK. If it becomes a performance issue, can always add a way disable it later.

JakeWharton commented 9 years ago

Want to send a PR? Otherwise I can do it at some point in the next week or two.

yhartanto commented 8 years ago

@JakeWharton, I updated the previous PR. It is always enabled now. https://github.com/JakeWharton/hugo/pull/100

JakeWharton commented 8 years ago

Merged. Will squeeze out a release in the next two weeks.