summaryrefslogtreecommitdiff
path: root/src/c
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-01-22 12:55:48 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-01-22 12:55:48 -0500
commit89bf98ed54da03267e0d49d7d71e8b7fe70b6ae4 (patch)
tree92801684abbf65eee3669d97bbbe53e3c2e7acf1 /src/c
parentc3b9f6d5c0a2194d3270737145dca7e39e4dfb10 (diff)
Using FastCGI debug info
Diffstat (limited to 'src/c')
-rw-r--r--src/c/fastcgi.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/c/fastcgi.c b/src/c/fastcgi.c
index 756ed3b0..1498580b 100644
--- a/src/c/fastcgi.c
+++ b/src/c/fastcgi.c
@@ -134,6 +134,8 @@ static int write_stdout(void *data, const char *buf, size_t len) {
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_error(void *data, const char *fmt, ...) {
}
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 {