17

I am trying to use TimingLogger for checking time consumed for a particular method and its statements. But Android TimingLogger is not able to print logs.

ASHOK KUMAR
  • 811
  • 6
  • 14

3 Answers3

51

If the Log.isLoggable is not enabled to at least the Log.VERBOSE level for that tag at creation time then the addSplit and dumpToLog call will do nothing.

If you simply looking for logs as explained in https://developer.android.com, you will not be able to see logs. So use below command in adb:

adb shell setprop log.tag.MyTag VERBOSE

Note: MyTag is the first parameter you passed when creating new TimingLogger as below:

TimingLogger timings = new TimingLogger("MyTag", "MyMethodName");

And there you are. Happy coding !!!

Community
  • 1
  • 1
ASHOK KUMAR
  • 811
  • 6
  • 14
2

Apart from changing the log level, I also had to reset the TimeLogger to set it's mDisabled flag. You can do so by timingLogger.reset()

Milan
  • 1,845
  • 5
  • 19
  • 33
  • Sometimes using only timingLogger.reset() logs do not show so in that case we have to run the command adb shell setprop log.tag.MyTag VERBOSE – singh.indolia Sep 20 '18 at 06:17
0

After the code is updated with timings.addSplit("MyTag:onviewcreated"); in all places , at last of the function you are working on, try calling timings.dumpToLog();

TimeLogger does not seem to work well inside async / background threads.

Reejesh
  • 1,745
  • 2
  • 6
  • 15