home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume6 / newbatcha / logger.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  1022 b   |  51 lines

  1. /*
  2.  *
  3.  *    logger.c - log info about nbatcher
  4.  *
  5.  *    R.J. Esposito
  6.  *    Bell of Penna.
  7.  *    June 1986
  8.  *
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <time.h>
  13. #include "nbatcher.h"
  14.  
  15. log_it (bytes)
  16. long    bytes;
  17. {
  18.     struct tm    *localtime(), *tp;
  19.     long    time(), clock;
  20.     char    logfile[80], buf[BUFSIZ];
  21.     char    pbuf[BUFSIZ];
  22.  
  23.     sprintf (logfile, "%s/%s", LIBDIR, "nbatcher.log");
  24.     if (log == NULL) {
  25.         if ((log=fopen(logfile, "a")) == NULL)
  26.            fprintf (stderr, "can't append to logfile\n");
  27.     }
  28.  
  29.     rewind (log, 0L, 2);    /* just incase */
  30.  
  31.     clock = time ((long *)0);
  32.     tp = localtime (&clock);
  33.     sprintf (buf, "%.2d/%.2d %.2d:%.2d %s: %d %s batched, %d %s queued\n",
  34.        tp->tm_mon+1, tp->tm_mday, tp->tm_hour, tp->tm_min, ep.site,
  35.        fcnt, (fcnt==1 ? "file" : "files"), scnt,
  36.        (scnt==1 ? "file" : "files"));
  37.  
  38.     if (bytes)
  39.        sprintf (pbuf, "%s\tmax bytes reached.  UUCP bytes was %ld, byte count = %ld\n",
  40.             buf, n_bytes, bytes);
  41.     else
  42.         sprintf (pbuf, "%s", buf);
  43.  
  44.     if (vflg)
  45.         fprintf (stdout, "%s",pbuf);
  46.  
  47.     if (log != NULL)
  48.         fputs (pbuf, log);
  49.  
  50. }
  51.