static FILE *logfile = NULL;
+static char *ctime1(char *buf2)
+{
+ time_t ti;
+ char *p;
+
+ ti = time(NULL);
+ p = ctime(&ti);
+ strcpy(buf2, p);
+ p = buf2 + strlen(p) - 1;
+ if (*p == '\n')
+ *p = '\0';
+ return buf2;
+}
+
static void __attribute__ ((format (printf, 1, 2))) http_log(const char *fmt, ...)
{
static int print_prefix = 1;
if (logfile) {
if (print_prefix) {
- time_t current = time(0);
- char buffer[32];
- strncpy(buffer, ctime(¤t), 31);
- buffer[strlen(buffer)-1] = 0; // remove '\n'
- fprintf(logfile, "%s ", buffer);
+ char buf[32];
+ ctime1(buf);
+ fprintf(logfile, "%s ", buf);
}
print_prefix = strstr(fmt, "\n") != NULL;
vfprintf(logfile, fmt, ap);
va_end(ap);
}
-static char *ctime1(char *buf2)
-{
- time_t ti;
- char *p;
-
- ti = time(NULL);
- p = ctime(&ti);
- strcpy(buf2, p);
- p = buf2 + strlen(p) - 1;
- if (*p == '\n')
- *p = '\0';
- return buf2;
-}
-
static void log_connection(HTTPContext *c)
{
char buf2[32];