java - Print logs on Android source code using Eclipse breakpoints? -
in debug effort understand system doing use java debugger conditional breakpoints mechanism print log messages on specific lines in android's source code.
how it? don't know, that's question about.
things know:
eclipse java debugger has "conditional breakpoints", i.e., set breakpoint in code , write condition. each time code reaches breakpoint line stop execution if condition wrote true
, otherwise not stop.
i though maybe mechanism can twisted print log message @ specific line in code instead of stopping execution. , if can done able track android's source code doing.
you can use following expression in conditional breakpoint:
android.util.log.v("myapp", "my message") == -1
this make breakpoints not break execution , in logcat view, filtering view using tag:myapp
expression, desired logged messages. can use other log levels (a
, i
, e
, w
). see log documentation more info.
to have breakpoint break, use:
android.util.log.v("myapp", "my message") >= 0
the return value of log.v
number of bytes log message internally has, positive number.
addendum: there more elegant way it. eclipse conditional breakpoints can java code, including using local variables @ breakpoint. last return value must true
if want stop execution or false
. same can achieved as:
android.util.log.v("myapp", "my message"); return false;
or can make more complicated statements like:
if( t.isnumber() ) { system.out.println("a number found"); } else { system.out.println("not number"); return true; // stops execution } android.util.log.v("myapp", "my message"); return false; // not stop execution
Comments
Post a Comment