4 * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
9 static char rcsid[] = "$Id$";
13 * Revision 1.5 2008/02/27 01:31:14 james
14 * *** empty log message ***
16 * Revision 1.4 2008/02/27 00:54:16 james
17 * *** empty log message ***
19 * Revision 1.3 2008/02/23 11:48:37 james
20 * *** empty log message ***
22 * Revision 1.2 2008/02/22 14:51:54 james
23 * *** empty log message ***
25 * Revision 1.1 2008/02/14 12:14:50 james
26 * *** empty log message ***
40 flog_log (Log * _l, char *buf)
42 File_Log *l = (File_Log *) _l;
43 struct timeval tv = { 0 };
46 static const char *days[] = { "Sun", "Mon", "Tue",
47 "Wed", "Thu", "Fri", "Sat"
49 static const char *months[] = {
50 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
57 gettimeofday (&tv, NULL);
61 fprintf (l->fp, "%s %2d %02d:%02d:%02d.%06d ", months[tm->tm_mon],
62 tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec);
75 File_Log *l = (File_Log *) _l;
76 if (l->fp && l->do_close)
82 file_log_new (char *fn)
88 if (fn && strcmp (fn, "-"))
100 l = malloc (sizeof (File_Log));
103 l->close = flog_close;
113 log_f (Log * log, char *fmt, ...)
136 n = vsnprintf (buf, size, fmt, ap);
139 if (n > -1 && n < size)
145 if (n > -1) /* glibc 2.1 */
148 size *= 2; /* twice the old size */
150 buf = realloc (buf, size);