From 8a2650980002dc4a17b7ef2cbe6fc7b0db36d686 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 12 Jan 2013 09:25:07 +0800 Subject: [PATCH] logging add timestamp Signed-off-by: Andy Green --- lib/libwebsockets.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 53e71e0f..78487612 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -3287,13 +3287,17 @@ void _lws_log(int filter, const char *format, ...) va_list ap; int n; int pos = 0; + struct timeval tv; if (!(log_level & filter)) return; + gettimeofday(&tv, NULL); + for (n = 0; n < LLL_COUNT; n++) if (filter == (1 << n)) { - pos = sprintf(buf, "%s: ", log_level_names[n]); + pos = sprintf(buf, "[%ld:%04ld] %s: ", tv.tv_sec, + tv.tv_usec / 100, log_level_names[n]); break; }