diff options
author | Yang Tse <yangsita@gmail.com> | 2007-02-16 19:41:25 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2007-02-16 19:41:25 +0000 |
commit | d46cab4a948dff620c88d67c873e76619b7768f1 (patch) | |
tree | 7237b4d8cafd397c71c52656a97d901b5d2ea6dc /tests/server/util.c | |
parent | 4dc453c08796da93eaa82a0af36029c265893300 (diff) | |
download | curl-d46cab4a948dff620c88d67c873e76619b7768f1.tar.gz |
add debug messages for fopen() failures
Diffstat (limited to 'tests/server/util.c')
-rw-r--r-- | tests/server/util.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/server/util.c b/tests/server/util.c index ce2bee639..d3d976c13 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -65,8 +65,14 @@ extern const char *serverlogfile; void logmsg(const char *msg, ...) { va_list ap; - char buffer[256]; /* possible overflow if you pass in a huge string */ + char buffer[512]; /* possible overflow if you pass in a huge string */ FILE *logfp; + int error; + + if (!serverlogfile) { + fprintf(stderr, "Error: serverlogfile not set\n"); + return; + } struct timeval tv = curlx_tvnow(); time_t sec = tv.tv_sec; @@ -86,13 +92,20 @@ void logmsg(const char *msg, ...) fprintf(logfp, "%s %s\n", timebuf, buffer); fclose(logfp); } + else { + error = ERRNO; + fprintf(stderr, "fopen() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "Error opening file: %s\n", serverlogfile); + fprintf(stderr, "Msg not logged: %s %s\n", timebuf, buffer); + } } #ifdef WIN32 /* use instead of perror() on generic windows */ void win32_perror (const char *msg) { - char buf[256]; + char buf[512]; DWORD err = SOCKERRNO; if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, |