Mercurial > urweb
changeset 1411:38d950c06dce
Using FastCGI debug info
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 22 Jan 2011 12:55:48 -0500 (2011-01-22) |
parents | 55d0c8b01d18 |
children | 5f4fee8a4dcd |
files | src/c/fastcgi.c |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <errno.h> + 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 {