summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/log.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/log.c b/src/log.c
index 46839ee..cd7c2d5 100644
--- a/src/log.c
+++ b/src/log.c
@@ -65,20 +65,26 @@ void usbmuxd_log(enum loglevel level, const char *fmt, ...)
{
va_list ap;
char *fs;
- struct timeval ts;
- struct tm *tp;
if(level > log_level)
return;
- get_tick_count(&ts);
- tp = localtime(&ts.tv_sec);
-
fs = malloc(20 + strlen(fmt));
if(log_syslog) {
sprintf(fs, "[%d] %s\n", level, fmt);
} else {
+ struct timeval ts;
+ struct tm tp_;
+ struct tm *tp;
+
+ gettimeofday(&ts, NULL);
+#ifdef HAVE_LOCALTIME_R
+ tp = localtime_r(&ts.tv_sec, &tp_);
+#else
+ tp = localtime(&ts.tv_sec);
+#endif
+
strftime(fs, 10, "[%H:%M:%S", tp);
sprintf(fs+9, ".%03d][%d] %s\n", (int)(ts.tv_usec / 1000), level, fmt);
}