diff options
author | Elliott Hughes <enh@google.com> | 2018-04-02 14:24:03 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2018-04-02 14:28:18 -0700 |
commit | 855cdf82f50824897eac9a5224afe2af9b5846cb (patch) | |
tree | 5eefdc81ba4e867ed2da390cad2d7883965d7442 /fastboot/util.cpp | |
parent | 194e27bf5e1c10b504781a06fabe19571b79c3dc (diff) | |
download | system_core-855cdf82f50824897eac9a5224afe2af9b5846cb.tar.gz system_core-855cdf82f50824897eac9a5224afe2af9b5846cb.tar.bz2 system_core-855cdf82f50824897eac9a5224afe2af9b5846cb.zip |
Improve fastboot verbose output.
Move some verbose messages so they're only output with -v.
Remove some misleading verbose messages altogether (such as "wiping
userdata...").
Properly log all the commands sent and responses received. Example:
$ fastboot -v flashall
...
Sending sparse 'system' 2/2 (443712 KB)
fastboot: verbose: sending command "download:1b1500d0"
fastboot: verbose: received DATA 1b1500d0
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (165596160 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (267762688 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (20978688 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (7168 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (3072 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (3072 bytes)
fastboot: verbose: sending data (1024 bytes)
fastboot: verbose: sending data (3072 bytes)
fastboot: verbose: sending data (208 bytes)
fastboot: verbose: received OKAY
OKAY [ 13.871s]
Writing sparse 'system' 2/2
fastboot: verbose: sending command "flash:system"
fastboot: verbose: received OKAY
OKAY [ 3.228s]
Rebooting
fastboot: verbose: sending command "reboot"
fastboot: verbose: received OKAY
Finished. Total time: 36.939s
Bug: http://b/30953083
Bug: http://b/74444116
Test: `fastboot -v flashall`
Change-Id: I2cca198daa062fd1fb732218343263803b111e38
Diffstat (limited to 'fastboot/util.cpp')
-rw-r--r-- | fastboot/util.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/fastboot/util.cpp b/fastboot/util.cpp index 53fc1be29..140270fd9 100644 --- a/fastboot/util.cpp +++ b/fastboot/util.cpp @@ -35,6 +35,8 @@ #include "fastboot.h" +static bool g_verbose = false; + double now() { struct timeval tv; gettimeofday(&tv, NULL); @@ -46,11 +48,28 @@ void die(const char* fmt, ...) { va_start(ap, fmt); fprintf(stderr, "fastboot: error: "); vfprintf(stderr, fmt, ap); - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); va_end(ap); exit(EXIT_FAILURE); } +void set_verbose() { + g_verbose = true; +} + +void verbose(const char* fmt, ...) { + if (!g_verbose) return; + + if (*fmt != '\n') { + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "fastboot: verbose: "); + vfprintf(stderr, fmt, ap); + va_end(ap); + } + fprintf(stderr, "\n"); +} + char* xstrdup(const char* s) { char* result = strdup(s); if (!result) die("out of memory"); |