aboutsummaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2009-05-25 18:17:55 -0400
committerMike Lockwood <lockwood@android.com>2009-05-25 18:17:55 -0400
commit1f546e6d1f6ccd1964336ddf0d8e8b3b11b1e945 (patch)
tree209175263e021386a66aaeda9a6dfb33456f0eec /adb
parent6a3075c78287ea5a7ee7a3c85cde58e894350822 (diff)
downloadsystem_core-1f546e6d1f6ccd1964336ddf0d8e8b3b11b1e945.tar.gz
system_core-1f546e6d1f6ccd1964336ddf0d8e8b3b11b1e945.tar.bz2
system_core-1f546e6d1f6ccd1964336ddf0d8e8b3b11b1e945.zip
adb: Allow enabling of device side adbd logging with a persistent system property.
To enable logging, set the property persist.adb.trace_mask to a hex value containing the bitmask for adb_trace_mask (see the TRACE_* enum values in adb.h). This will result in adb writing log output to a file in /data/adb/ No logging will occur if persist.adb.trace_mask is not set or has a value that cannot be parsed as a hex integer. The property is read once only at startup, so you must reboot or restart adbd for changes in the property to take effect. Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'adb')
-rw-r--r--adb/adb.c30
-rw-r--r--adb/adb.h5
2 files changed, 20 insertions, 15 deletions
diff --git a/adb/adb.c b/adb/adb.c
index 203e7d29..956df544 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -23,6 +23,7 @@
#include <errno.h>
#include <string.h>
#include <time.h>
+#include <sys/time.h>
#include "sysdeps.h"
#include "adb.h"
@@ -657,10 +658,25 @@ void start_logging(void)
void start_device_log(void)
{
int fd;
- char path[100];
+ char path[PATH_MAX];
+ struct tm now;
+ time_t t;
+ char value[PROPERTY_VALUE_MAX];
+
+ // read the trace mask from persistent property persist.adb.trace_mask
+ // give up if the property is not set or cannot be parsed
+ property_get("persist.adb.trace_mask", value, "");
+ if (sscanf(value, "%x", &adb_trace_mask) != 1)
+ return;
- snprintf(path, sizeof path, "/data/adb_%ld.txt", (long)time(NULL));
- fd = unix_open(path, O_WRONLY | O_CREAT | O_APPEND, 0640);
+ adb_mkdir("/data/adb", 0775);
+ tzset();
+ time(&t);
+ localtime_r(&t, &now);
+ strftime(path, sizeof(path),
+ "/data/adb/adb-%Y-%m-%d-%H-%M-%S.txt",
+ &now);
+ fd = unix_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640);
if (fd < 0)
return;
@@ -671,11 +687,6 @@ void start_device_log(void)
fd = unix_open("/dev/null", O_RDONLY);
dup2(fd, 0);
-
- // log everything
- adb_trace_mask = ~0;
- // except TRACE_RWX is a bit too verbose
- adb_trace_mask &= ~TRACE_RWX;
}
#endif
@@ -1079,9 +1090,8 @@ int main(int argc, char **argv)
adb_device_banner = "recovery";
recovery_mode = 1;
}
-#if ADB_DEVICE_LOG
+
start_device_log();
-#endif
return adb_main(0);
#endif
}
diff --git a/adb/adb.h b/adb/adb.h
index 3c4fe603..b9ed5560 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -345,11 +345,6 @@ typedef enum {
#endif
-/* set this to log to /data/adb/adb_<time>.txt on the device.
- * has no effect if the /data/adb/ directory does not exist.
- */
-#define ADB_DEVICE_LOG 0
-
#if !TRACE_PACKETS
#define print_packet(tag,p) do {} while (0)
#endif