comparison rvinterf/log.c @ 134:e0d56e9be8a2

rvtdump: time-stamped logging implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 02 Nov 2013 23:15:42 +0000
parents
children 4d8e4c58df71
comparison
equal deleted inserted replaced
133:56b53c289785 134:e0d56e9be8a2
1 /*
2 * This module implements the logging function
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <strings.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <time.h>
12
13 extern char pr_item[];
14
15 extern FILE *logF;
16 extern time_t logtime;
17
18 static struct tm last_tm;
19
20 log_item()
21 {
22 struct tm *curtm;
23
24 curtm = gmtime(&logtime);
25 if (curtm->tm_year != last_tm.tm_year ||
26 curtm->tm_mon != last_tm.tm_mon ||
27 curtm->tm_mday != last_tm.tm_mday)
28 fprintf(logF, "%d-%02d-%02d (gmtime):\n", curtm->tm_year + 1900,
29 curtm->tm_mon+1, curtm->tm_mday);
30 fprintf(logF, "[%02d:%02d:%02d] %s\n", curtm->tm_hour, curtm->tm_min,
31 curtm->tm_sec, pr_item);
32 bcopy(curtm, &last_tm, sizeof(struct tm));
33 }