summaryrefslogtreecommitdiffstats
path: root/PICA_log.c
diff options
context:
space:
mode:
authorme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2012-08-26 20:38:20 +0000
committerme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2012-08-26 20:38:20 +0000
commit7381aef2e02aa6493e309409e3e9d10212b7c245 (patch)
tree3719cbbead4e6069e6f7c4003ecb33d0a5bb50eb /PICA_log.c
parentc58f253f9551fa9850a67129fd02223ec055dc13 (diff)
downloadpica-pica-7381aef2e02aa6493e309409e3e9d10212b7c245.tar.gz
pica-pica-7381aef2e02aa6493e309409e3e9d10212b7c245.zip
date and time in log output
git-svn-id: svn://localhost/project_picapica/trunk@191 fb96df88-216d-11de-830c-f3023f12d8ac
Diffstat (limited to 'PICA_log.c')
-rw-r--r--PICA_log.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/PICA_log.c b/PICA_log.c
index 81ea39c..c20edf2 100644
--- a/PICA_log.c
+++ b/PICA_log.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
static int PICA_loglevel = PICA_LOG_INFO;
@@ -83,11 +84,17 @@ void PICA_log_entry(int loglevel, const char *fmt, va_list args)
static char buf[1024];
static const char *loglevel_txt[] = {"fatal", "error", "warning", "info", "debug1", "debug2", "debug3"};
FILE *log_file = stdout;
+time_t log_time;
+static char timebuf[32];
if (loglevel <= PICA_LOG_WARN)
log_file = stderr;
-sprintf(buf, "%s: %.1000s\n", loglevel_txt[loglevel - PICA_LOG_FATAL], fmt);
+log_time = time(NULL);
+strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", localtime(&log_time));
+
+
+sprintf(buf, "[%.32s] %s: %.1000s\n", timebuf, loglevel_txt[loglevel - PICA_LOG_FATAL], fmt);
vfprintf(log_file, buf, args);
}