home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- #include <stdarg.h>
- #include "cus.h"
- #include "defines.h"
- #include "dbg.h"
-
-
- void ulog(char *logfile, char *logprog, char *loghost, char *fmtstr, ...)
- {
- long t;
- struct tm *tm;
- char logtxt[RANGE_7BIT];
- char logline[RANGE_8BIT];
- FILE *fp = NULL;
- va_list argptr;
-
- va_start(argptr, fmtstr);
- vsprintf(logtxt, fmtstr, argptr);
-
- (void)time(&t); /* get timeoffset */
- tm = localtime(&t); /* unpack timeoffset to local time */
-
- sprintf(logline, "(%02d/%02d-%02d:%02d:%02d) %s,%s,- %s\n",
- tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
- logprog, loghost, logtxt );
-
- if (fp = fopen(logfile, "a")) {
- fseek(fp, 0L, SEEK_END);
- fwrite(logline, strlen(logline), 1, fp);
- fclose(fp);
- }
-
- dbg(1, "logentry: %s", logline);
- va_end(argptr);
- return;
- }
-
-