# HG changeset patch # User Adam Chlipala # Date 1295718948 18000 # Node ID 38d950c06dce7480ae38f3533be5022c72a166c6 # Parent 55d0c8b01d18c719652d08ece6a2d4bf3c69933d Using FastCGI debug info diff -r 55d0c8b01d18 -r 38d950c06dce src/c/fastcgi.c --- a/src/c/fastcgi.c Sat Jan 22 10:53:06 2011 -0500 +++ b/src/c/fastcgi.c Sat Jan 22 12:55:48 2011 -0500 @@ -134,6 +134,8 @@ return 0; } +#include + static void write_stderr(FCGI_Output *o, const char *fmt, ...) { int len; va_list ap; @@ -167,6 +169,24 @@ } static void log_debug(void *data, const char *fmt, ...) { + FCGI_Output *o = (FCGI_Output *)data; + va_list ap; + va_start(ap, fmt); + + if (o) { + strcpy((char *)o->r.contentData, "DEBUG: "); + int len = vsnprintf((char *)o->r.contentData + 7, 65535 - 7, fmt, ap); + if (len < 0) + fprintf(stderr, "vsnprintf() failed in log_debug().\n"); + else if (fastcgi_send(o, FCGI_STDERR, len + 7)) { + len += 7; + if (len >= 65535) len = 65534; + o->r.contentData[len] = 0; + fputs((char *)o->r.contentData, stderr); + fflush(stderr); + } + } else + vfprintf(stderr, fmt, ap); } typedef struct {