Add LOG_LEVEL_RECEIVED to log the not-yet-parsed data received.
authorFabian Keil <fk@fabiankeil.de>
Mon, 26 Jul 2010 11:28:11 +0000 (11:28 +0000)
committerFabian Keil <fk@fabiankeil.de>
Mon, 26 Jul 2010 11:28:11 +0000 (11:28 +0000)
This should make debugging various parsing issues a lot easier.

errlog.c
errlog.h
jbsockets.c

index f352f9f..3416709 100644 (file)
--- a/errlog.c
+++ b/errlog.c
@@ -1,4 +1,4 @@
-const char errlog_rcs[] = "$Id: errlog.c,v 1.106 2010/07/26 11:21:47 fabiankeil Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 1.107 2010/07/26 11:24:34 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/errlog.c,v $
@@ -575,6 +575,9 @@ static inline const char *get_log_level_string(int loglevel)
       case LOG_LEVEL_LOG:
          log_level_string = "Writing";
          break;
+      case LOG_LEVEL_RECEIVED:
+         log_level_string = "Received";
+         break;
       case LOG_LEVEL_HEADER:
          log_level_string = "Header";
          break;
index 75ae4c2..7c282fa 100644 (file)
--- a/errlog.h
+++ b/errlog.h
@@ -1,6 +1,6 @@
 #ifndef ERRLOG_H_INCLUDED
 #define ERRLOG_H_INCLUDED
-#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.23 2009/05/16 13:27:20 fabiankeil Exp $"
+#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.24 2010/07/21 14:43:03 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/errlog.h,v $
@@ -57,6 +57,7 @@ extern "C" {
 #define LOG_LEVEL_CLF        0x0200 /* Common Log File format */
 #define LOG_LEVEL_CRUNCH     0x0400
 #define LOG_LEVEL_CGI        0x0800 /* CGI / templates */
+#define LOG_LEVEL_RECEIVED   0x8000
 
 /* Following are always on: */
 #define LOG_LEVEL_INFO    0x1000
index d060a06..349a14c 100644 (file)
@@ -1,4 +1,4 @@
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.76 2010/06/13 12:30:10 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.77 2010/07/26 11:26:26 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
@@ -559,18 +559,27 @@ int write_socket(jb_socket fd, const char *buf, size_t len)
  *********************************************************************/
 int read_socket(jb_socket fd, char *buf, int len)
 {
+   int ret;
+
    if (len <= 0)
    {
       return(0);
    }
 
 #if defined(_WIN32)
-   return(recv(fd, buf, len, 0));
+   ret = recv(fd, buf, len, 0);
 #elif defined(__BEOS__) || defined(AMIGA) || defined(__OS2__)
-   return(recv(fd, buf, (size_t)len, 0));
+   ret = recv(fd, buf, (size_t)len, 0);
 #else
-   return((int)read(fd, buf, (size_t)len));
+   ret = (int)read(fd, buf, (size_t)len);
 #endif
+
+   if (ret > 0)
+   {
+      log_error(LOG_LEVEL_RECEIVED, "from socket %d: %N", fd, ret, buf);
+   }
+
+   return ret;
 }