4 * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
9 static char rcsid[] = "$Id$";
13 * Revision 1.2 2008/02/22 14:51:54 james
14 * *** empty log message ***
16 * Revision 1.1 2008/02/14 12:14:50 james
17 * *** empty log message ***
31 flog_log (Log * _l, char *buf)
33 File_Log *l = (File_Log *) _l;
34 struct timeval tv = { 0 };
37 static const char *days[] = { "Sun", "Mon", "Tue",
38 "Wed", "Thu", "Fri", "Sat"
40 static const char *months[] = {
41 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
48 gettimeofday (&tv, NULL);
52 fprintf (l->fp, "%s %2d %02d:%02d:%02d.%06d ", months[tm->tm_mon],
53 tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec);
66 File_Log *l = (File_Log *) _l;
67 if (l->fp && l->do_close)
73 file_log_new (char *fn)
79 if (fn && strcmp(fn,"-")) {
88 l = malloc (sizeof (File_Log));
91 l->close = flog_close;
98 log_f (Log *log,char *fmt, ...)
119 n = vsnprintf (buf , size, fmt, ap);
122 if (n > -1 && n < size) {
127 if (n > -1) /* glibc 2.1 */
130 size *= 2; /* twice the old size */
132 buf = realloc (buf, size);