mturk       2004/11/11 09:03:29

  Modified:    jk/native/common jk_msg_buff.c
  Log:
  Backport message dumping from JK2.
  The message will dump if loglevel is trace
  
  Revision  Changes    Path
  1.22      +49 -7     jakarta-tomcat-connectors/jk/native/common/jk_msg_buff.c
  
  Index: jk_msg_buff.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_msg_buff.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- jk_msg_buff.c     11 Nov 2004 11:56:22 -0000      1.21
  +++ jk_msg_buff.c     11 Nov 2004 17:03:29 -0000      1.22
  @@ -39,11 +39,15 @@
       int maxlen;
   };
   
  +static char *jk_HEX = "0123456789ABCDEFX";
   
   /*
    * Simple marshaling code.
    */
   
  +/* Deprecated: We need smarter way for that.
  +   Do not use stderr for logging
  + */
   #if defined(DEBUG) || defined(_DEBUG)
   static void jk_b_dump(jk_msg_buf_t *msg, char *err)
   {
  @@ -388,12 +392,50 @@
                     int line, const char *funcname,
                     int level, char *what, jk_msg_buf_t *msg)
   {
  -#ifdef USE_ALSO_BODY
  -    jk_log(l, file, line, funcname, level, "%s #%d %.*s\n",
  -           what, jk_b_get_len(msg), jk_b_get_len(msg), jk_b_get_buff(msg));
  -#else
  -    jk_log(l, file, line, funcname, level, "%s #%d\n", what, 
jk_b_get_len(msg));
  -#endif
  +    int i = 0;
  +    char lb[80];
  +    char *current;
  +    int j;
  +    int len = msg->len;
  +
  +    if (l->level == JK_LOG_DEBUG_LEVEL) {
  +        len = 0;
  +    }
  +    else if (len > 1024)
  +        len = 1024;
  +
  +    jk_log(l, file, line, funcname, level,
  +           "%s pos=%d len=%d max=%d \n",
  +           what, msg->pos, msg->len, msg->maxlen);
  +
  +    for (i = 0; i < len; i += 16) {
  +        current = &lb[0];
  +
  +        for (j = 0; j < 16; j++) {
  +            unsigned char x = (msg->buf[i + j]);
  +
  +            *current++ = jk_HEX[x >> 4];
  +            *current++ = jk_HEX[x & 0x0f];
  +            *current++ = ' ';
  +        }
  +        *current++ = ' ';
  +        *current++ = '-';
  +        *current++ = ' ';
  +        for (j = 0; j < 16; j++) {
  +            unsigned char x = msg->buf[i + j];
  +
  +            if (x > 0x20 && x < 0x7F) {
  +                *current++ = x;
  +            }
  +            else {
  +                *current++ = '.';
  +            }
  +        }
  +        *current++ = '\n';
  +        *current++ = '\0';
  +            jk_log(l, file, line, funcname, level,
  +                   "%.4x    %s", i, line);
  +    }
   }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to