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/dumpstate.h b/cmds/dumpstate/dumpstate.h
index a6afbf4..5a93f8c 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -29,6 +29,17 @@
#define ON_DRY_RUN(code)
#endif
+#ifndef MYLOGD
+#define MYLOGD(fmt...) fprintf(stderr, fmt); ALOGD(fmt);
+#endif
+
+#ifndef MYLOGI
+#define MYLOGI(fmt...) fprintf(stderr, fmt); ALOGI(fmt);
+#endif
+
+#ifndef MYLOGE
+#define MYLOGE(fmt...) fprintf(stderr, fmt); ALOGE(fmt);
+#endif
#include <time.h>
#include <unistd.h>