home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / uupoll068.lha / misc / uupoll067.lha / src / log.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-16  |  830 b   |  41 lines

  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <stdarg.h>
  6. #include "cus.h"
  7. #include "defines.h"
  8. #include "dbg.h"
  9.  
  10.  
  11. void ulog(char *logfile, char *logprog, char *loghost, char *fmtstr, ...)
  12. {
  13.     long t;
  14.     struct tm *tm;
  15.     char logtxt[RANGE_7BIT];
  16.     char logline[RANGE_8BIT];
  17.     FILE *fp = NULL;
  18.     va_list argptr;
  19.  
  20.     va_start(argptr, fmtstr);
  21.     vsprintf(logtxt, fmtstr, argptr);
  22.  
  23.     (void)time(&t); /* get timeoffset */
  24.     tm = localtime(&t); /* unpack timeoffset to local time */
  25.  
  26.     sprintf(logline, "(%02d/%02d-%02d:%02d:%02d) %s,%s,- %s\n",
  27.             tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
  28.             logprog, loghost, logtxt );
  29.  
  30.     if (fp = fopen(logfile, "a")) {
  31.         fseek(fp, 0L, SEEK_END);
  32.         fwrite(logline, strlen(logline), 1, fp);
  33.         fclose(fp);
  34.     }
  35.  
  36.     dbg(1, "logentry: %s", logline);
  37.     va_end(argptr);
  38.     return;
  39. }
  40.  
  41.