Logfile entries

From: Nigel Horne <njh_at_bandsman.co.uk>
Date: Mon, 27 Aug 2007 09:19:45 +0100

1) Entries in the logfile aren't flushed so you often have to wait sometime for the
log to include the latest statement.

Add "fflush(fp)" to the end of output_file()

2) Entries in the logfile should include a timestamp

3) Errors aren't always seen if you're not running in the background. Add a call to output_file()
in error().

This patch includes all my patches to pen 0.17.1. I haven't yet done the timestamp one.

------------------------------------------

*** Open.c 2007-08-27 08:53:40.000000000 +0100
--- pen.c 2007-08-27 09:16:45.000000000 +0100
***************
*** 179,184 ****
--- 179,186 ----
  
  static struct sigaction alrmaction, hupaction, termaction, usr1action;
  
+ static void output_file(char *b, void *op);
+
  static void debug(char *fmt, ...)
  {
        time_t now;
***************
*** 214,219 ****
--- 216,223 ----
                syslog(LOG_ERR, "%s\n", b);
                closelog();
        }
+ if(logfile)
+ output_file(b, logfile);
        va_end(ap);
        exit(1);
  }
***************
*** 241,248 ****
  
  static char *pen_strdup(char *p)
  {
! char *b = pen_malloc(strlen(p)+1);
! return strcpy(b, p);
  }
  
  static int pen_strncasecmp(const char *p, const char *q, size_t n)
--- 245,258 ----
  
  static char *pen_strdup(char *p)
  {
! size_t len = strlen(p);
! char *b = pen_malloc(len + 1);
!
! if(b) {
! memcpy(b, p, len);
! b[len] = '\0';
! }
! return b;
  }
  
  static int pen_strncasecmp(const char *p, const char *q, size_t n)
***************
*** 1692,1698 ****
--- 1702,1710 ----
  static void output_file(char *b, void *op)
  {
        FILE *fp = op;
+
        fputs(b, fp);
+ fflush(fp);
  }
  
  static void do_ctrl(int downfd, struct sockaddr_in *cli_addr)

-- 
Nigel Horne. Adjudicator, Arranger, Band Trainer, Composer, Tutor, Typesetter.
NJH Music, Barnsley, UK.  ICQ#20252325
njh@bandsman.co.uk http://www.bandsman.co.uk

Received on Mon Aug 27 2007 - 10:22:19 CEST

This archive was generated by hypermail 2.2.0 : Mon Aug 27 2007 - 10:22:20 CEST