Status: Closed (View Workflow)
Currently, the plugin will wait for the emulator to finish booting, unlock the screen, wait for it to settle a bit, and then take a snapshot.
That means any subsequent reuse of that snapshot will contain the log buffer at the time the snapshot was taken, followed by a sudden change to the current log buffer. Example:
05-25 23:21:45.774 D/MediaScannerService( 222): done scanning volume external 05-25 23:22:30.574 E/ThrottleService( 72): Error reading data file 05-25 23:22:31.804 D/AlarmManagerService( 72): Kernel timezone updated to 240 minutes west of GMT 05-25 23:22:31.814 D/SystemClock( 139): Setting time of day to sec=1306923524 06-01 06:18:44.092 W/SystemClock( 139): Unable to set rtc to 1306923524: Invalid argument 06-01 06:18:44.272 D/AlarmManagerService( 72): Kernel timezone updated to 240 minutes west of GMT 06-01 06:18:49.382 D/dalvikvm( 206): GC_EXPLICIT freed 1530 objects / 121432 bytes in 100ms 06-01 06:19:00.162 D/dalvikvm( 72): GC_FOR_MALLOC freed 12506 objects / 741024 bytes in 162ms
To prevent that, it would be useful to run the "adb -e logcat -c" command, which will clear the logcat buffer, immediately before taking the snapshot. You might even emit your own log message right after that, so that the top of every logcat archived will show the date/time from when the snapshot was created:
$ adb -e logcat -c $ adb -e shell log -p v -t Jenkins "Creating snapshot..."
It'll put this in the log:
$ adb -e logcat -v time -d | tail -n1 06-01 13:24:02.057 V/Jenkins ( 517): Creating snapshot...
Then create the snapshot from there.
Yup, for reference:
$ adb -e shell log USAGE: log [-p priorityChar] [-t tag] message priorityChar should be one of: v,d,i,w,e
and I'm sure you've already seen all this, but just in case (it's not immediately obvious how to get this, especially since adb logcat --help does not work):
$ adb -d shell logcat --help Usage: logcat [options] [filterspecs] options include: -s Set default filter to silent. Like specifying filterspec '*:s' -f <filename> Log to file. Default to stdout -r [<kbytes>] Rotate log every kbytes. (16 if unspecified). Requires -f -n <count> Sets max number of rotated logs to <count>, default 4 -v <format> Sets the log print format, where <format> is one of: brief process tag thread raw time threadtime long -c clear (flush) the entire log and exit -d dump the log and then exit (don't block) -t <count> print only the most recent <count> lines (implies -d) -g get the size of the log's ring buffer and exit -b <buffer> request alternate ring buffer ('main' (default), 'radio', 'events') -B output the log in binary -C colored output filterspecs are a series of <tag>[:priority] where <tag> is a log component tag (or * for all) and priority is: V Verbose D Debug I Info W Warn E Error F Fatal S Silent (supress all output) '*' means '*:d' and <tag> by itself means <tag>:v If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS. If no filterspec is found, filter defaults to '*:I' If not specified with -v, format is set from ANDROID_PRINTF_LOG or defaults to "brief"
Code changed in jenkins
User: Christopher Orr
[FIXED JENKINS-9831] Clear emulator logs before creating first snapshot.
This prevents all the initial start-up logcat output from being
redundantly included in every subsequent build that uses this snapshot.
Ah yes, I had noticed that problem. I didn't know you could directly add logs though.. thanks for that.
I'll get this into the next release.