Forum OpenACS Q&A: patch to dump arbitary hex/ascii to server log

I have a patch, ns_logdump, at http://www.theashergroup .com/download/, that adds a Tcl and C API to AOLserver to dump arbitrary hex/ascii strings into the log file.

Dump a string in hex and ascii to the log. Available from C or Tcl. Useful in debugging new protocols

Add a C API and Tcl API for dumping HEX to the log.

void Ns_LogDumpString(Ns_LogSeverity severity, char *s,  int len)

ns_logdump severity string
Severity is a standard ns_log severity constant, Notice, Warning, Error, Debug, or Dev.

The output in the log file looks like:

0000: 4164 6420 6120 4320 4150 4920 616e 6420  Add a C API and
0010: 5463 6c20 4150 4920 666f 7220 6475 6d70  Tcl API for dump
0020: 696e 6720 4845 5820 746f 2074 6865 206c  ing HEX to the l
0030: 6f67 2e0a 0a76 6f69 6420 4e73 5f4c 6f67  og...void Ns_Log
0040: 4475 6d70 5374 7269 6e67 284e 735f 4c6f  DumpString(Ns_Lo
The length of a line is controlled by a tcl config parameter, dumpbytesperline, that defaults to 32.
  ns_section      ns/parameters
  ns_param        dumpbytesperline   32
This patch modifies: nsd/log.c, nsd/nsconf.c, nsd/nsconf.h, nsd/nsd.h, nsd/tclcmds.c.
I have found this useful in hooking the ACS up to new services (Tellme, Voxeo, SOAP), or when trying to determine how to ns_httpget binaries.