From bc9583f9f05c86aa21da0d1b9081660a64d9ce31 Mon Sep 17 00:00:00 2001 From: mihaf <miha.fosnaric@gmail.com> Date: Wed, 26 Mar 2014 14:06:52 +0000 Subject: [PATCH] pswitch can be changed on the fly. --- src/general.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/general.c b/src/general.c index b078f87..a600800 100644 --- a/src/general.c +++ b/src/general.c @@ -3,9 +3,21 @@ #include "general.h" #include<stdarg.h> -ts_uint ts_fprintf(FILE *fd, char *fmt, va_list ap){ +#include <sys/time.h> +#include <unistd.h> +#include <time.h> + + +ts_uint ts_fprintf(FILE *fd, char *fmt, ...){ if(quiet) return TS_SUCCESS; -fprintf(fd, fmt, ap); /* Call vprintf */ + va_list ap; + va_start(ap,fmt); + char tmbuf[255]; + struct timeval now; + gettimeofday(&now, 0); + strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", localtime(&now.tv_sec)); +fprintf(fd, "[%s] ",tmbuf); +vfprintf(fd, fmt, ap); /* Call vfprintf */ va_end(ap); /* Cleanup the va_list */ return TS_SUCCESS; } -- Gitblit v1.9.3