Improved dumpstate logging.
dumpstate generates 3 types of output:
- stdout: used for the bugreport itself and is redirected to a file
if requested.
- stderr: used for errors, is only useful when dumpstate is called from
adb (otherwise is ignored).
- ALOG: logged into logcat and available in the bugreport.
This current approach has 2 problems:
- stderr output is ignored when dumpstatet is called from bugreport
services.
- bugs on dumpstate are often hard to diagnose
(AKA 'Who watches the watchmen?').
This change mitigates these problems by redirecting stderr into a log
file (which will also be included in the bugreport notification) and by
keeping the .tmp file around (for the extreme cases where the .zip file
could not be generated or got corrupted).
BUG: 26906985
Change-Id: I73e7b1dd10ad9f83b7aa1043131ff3b74c426fdb
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index 0c35430..683091f 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -78,7 +78,7 @@
fprintf(out_, "------ %.3fs was the duration of '%s' ------\n",
(float) elapsed / NANOS_PER_SEC, title_);
} else {
- ALOGD("Duration of '%s': %.3fs\n", title_, (float) elapsed / NANOS_PER_SEC);
+ MYLOGD("Duration of '%s': %.3fs\n", title_, (float) elapsed / NANOS_PER_SEC);
}
}
}
@@ -671,11 +671,11 @@
if (chp) {
*chp = 0;
if (stat(path, &dir_stat) == -1 || !S_ISDIR(dir_stat.st_mode)) {
- ALOGI("Creating directory %s\n", path);
+ MYLOGI("Creating directory %s\n", path);
if (mkdir(path, 0770)) { /* drwxrwx--- */
- ALOGE("Unable to create directory %s: %s\n", path, strerror(errno));
+ MYLOGE("Unable to create directory %s: %s\n", path, strerror(errno));
} else if (chown(path, AID_SHELL, AID_SHELL)) {
- ALOGE("Unable to change ownership of dir %s: %s\n", path, strerror(errno));
+ MYLOGE("Unable to change ownership of dir %s: %s\n", path, strerror(errno));
}
}
*chp++ = '/';
@@ -907,7 +907,7 @@
sprintf(value, "%d", weight_total);
int status = property_set(key, value);
if (status) {
- ALOGW("Could not update max weight by setting system property %s to %s: %d\n",
+ MYLOGE("Could not update max weight by setting system property %s to %s: %d\n",
key, value, status);
}
}
@@ -921,7 +921,7 @@
int status = property_set(key, value);
if (status) {
- ALOGW("Could not update progress by setting system property %s to %s: %d\n",
+ MYLOGE("Could not update progress by setting system property %s to %s: %d\n",
key, value, status);
}
}