summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-04-29 19:03:13 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-04-29 19:03:35 +0200
commit0c6200cd5ff4d0cdd3a6666669e896573bb2d0a4 (patch)
tree66823032c0e811e516eef5aa25b994354f8027e1
parent20ae5c63cfb532605cc78f9b7cda9cc680aaae20 (diff)
downloadltunify-0c6200cd5ff4d0cdd3a6666669e896573bb2d0a4.tar.gz
read-dev-usbmon: prepend time to message
-rw-r--r--read-dev-usbmon.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/read-dev-usbmon.c b/read-dev-usbmon.c
index a20ed89..bd1c1a6 100644
--- a/read-dev-usbmon.c
+++ b/read-dev-usbmon.c
@@ -27,6 +27,8 @@
#include <stdint.h>
#include <stdlib.h> /* getenv */
#include <errno.h>
+#include <sys/time.h> /* gettimeofday */
+#include <time.h> /* localtime */
typedef uint16_t u16;
typedef int32_t s32;
@@ -78,6 +80,20 @@ struct mon_get_arg {
#include "hidraw.c"
#undef NO_MAIN
+void print_time(void) {
+ struct timeval tval;
+ struct tm *tm;
+
+ if (gettimeofday(&tval, NULL)) {
+ perror("gettimeofday");
+ return;
+ }
+ tm = localtime(&tval.tv_sec);
+ printf("%02d:%02d:%02d.%03ld ",
+ tm->tm_hour, tm->tm_min, tm->tm_sec,
+ tval.tv_usec / 1000);
+}
+
int main(int argc, char ** argv) {
unsigned char data[1024];
struct usbmon_packet hdr;
@@ -131,6 +147,7 @@ int main(int argc, char ** argv) {
continue;
}
#define COLOR(c, cstr) "\033[" c "m" cstr "\033[m"
+ print_time();
if (hdr.type == 'C') {
printf(COLOR("1;32", "Recv\t"));
} else if (hdr.type == 'S') {