home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 December / CHIPNET Aralık 1997.iso / linux / redhat / misc / src / install / log.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-11  |  795 b   |  46 lines

  1. #include <fcntl.h>
  2. #include <stdarg.h>
  3. #include <stdio.h>
  4. #include <unistd.h>
  5.  
  6. #include "log.h"
  7.  
  8. FILE * logfile = NULL;
  9. int logfd;
  10.  
  11. void doLogMessage(char * s, ...) {
  12.     va_list args;
  13.  
  14.     if (!logfile) return;
  15.  
  16.     va_start(args, s);
  17.     fprintf(logfile, "* ");
  18.     vfprintf(logfile, s, args);
  19.     fprintf(logfile, "\n");
  20.     va_end(args);
  21.  
  22.     fflush(logfile);
  23. }
  24.  
  25. void openLog(void) {
  26.     if (!testing) {
  27.     logfile = fopen("/dev/tty3", "w");
  28.     if (logfile)
  29.         logfd = open("/dev/tty3", O_WRONLY);
  30.     else {
  31.         logfile = fopen("/tmp/install.log", "a");
  32.         logfd = open("/tmp/install.log", O_WRONLY| O_APPEND);
  33.     }
  34.     } else {
  35.     logfile = fopen("debug.log", "w");
  36.     logfd = open("debug.log", O_WRONLY);
  37.     }
  38. }
  39.  
  40. void closeLog(void) {
  41.     if (logfile) {
  42.     fclose(logfile);
  43.     close(logfd);
  44.     }
  45. }
  46.