annotate rvinterf/log.c @ 153:65efffcb28dc

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