Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-9831

Clear logcat before snapshot

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          orrc Christopher Orr added a comment -

          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.

          Show
          orrc Christopher Orr added a comment - 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.
          Hide
          jhansche Joe Hansche added a comment -

          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"
          
          Show
          jhansche Joe Hansche added a comment - 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"
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Christopher Orr
          Path:
          src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java
          http://jenkins-ci.org/commit/android-emulator-plugin/0e9e7cc20aec4c08d9bbcceda218d835e2ca6b54
          Log:
          [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.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christopher Orr Path: src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java http://jenkins-ci.org/commit/android-emulator-plugin/0e9e7cc20aec4c08d9bbcceda218d835e2ca6b54 Log: [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.
          Hide
          orrc Christopher Orr added a comment -

          Version 1.16 has now been released, which includes this update.

          Show
          orrc Christopher Orr added a comment - Version 1.16 has now been released, which includes this update.

            People

            • Assignee:
              orrc Christopher Orr
              Reporter:
              jhansche Joe Hansche
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: