author | Alberto Bertogli
<albertito@gmail.com> 2007-08-08 21:28:50 UTC |
committer | Alberto Bertogli
<albertito@gmail.com> 2007-08-08 21:28:50 UTC |
parent | 133b2d45c489cc371e50344977c4ce01d06c4b8f |
nmdb/log.c | +9 | -1 |
diff --git a/nmdb/log.c b/nmdb/log.c index a5c0725..9443a6d 100644 --- a/nmdb/log.c +++ b/nmdb/log.c @@ -36,17 +36,25 @@ int log_init(void) void wlog(const char *fmt, ...) { - int r; + int r, tr; va_list ap; char str[MAX_LOG_STR]; + char timestr[MAX_LOG_STR]; + time_t t; + struct tm *tmp; if (logfd == -1) return; + t = time(NULL); + tmp = localtime(&t); + tr = strftime(timestr, MAX_LOG_STR, "%F %H:%M:%S ", tmp); + va_start(ap, fmt); r = vsnprintf(str, MAX_LOG_STR, fmt, ap); va_end(ap); + write(logfd, timestr, tr); write(logfd, str, r); }