Trace the communication between a client and the server.
This class is enabled if the Barracuda Web-Server library is compiled with macro HTTP_TRACE enabled. The methods in this class have no effect if the trace functionality is not enabled by macro HTTP_TRACE. You must also provide a console callback function before the trace functionality is activated. See HttpTrace::setFLushCallback for more information.
Most user functions in the web-server return 0 on success and an error number if any of the parameters were incorrect. The web-server also prints the error to the trace buffer, and it is for this reason recommended that you always provide a trace callback function when doing development.
The trace library is typically used by your code when debugging. The printf and write member functions take the message priority as argument. You can, therefore, design the code such that more important functions use a higher priority. See HttpTrace::setPrio for more information.
The web-server is using the trace library to write information about user requests and response data. This is by default disabled. If enabled, the web-server writes the data to the trace buffer by using priority 5. See the setXXX functions for more information.
The trace callback function can write to internal memory, your screen (if you have one) or use an SMTP library.
Here is a trace callback function example that is using the SMTP library:
static void flushTrace(char* buf, int bufLen)
{
const char* from = "device1@realtimelogic.com";
const char* to = "bill@mycompany.com";
const char* subject = "DEVICE 1 TRACE DATA";
const char* smtpServer = "192.168.0.1";
SMTP smtp(from, to, subject, smtpServer);
smtp.write(buf, bufLen);
}
void myInit(void)
{
}
static void setFLushCallback(HttpTrace_Flush fcb)
The HTTP_TRACE compile time macro adds the trace library to the Barracuda library,...
Definition: HttpTrace.h:374
static int setBufSize(int size)
Set trace buffer size.
Definition: HttpTrace.h:403
static void setRequest(bool cmd)
Enable or disable request-line tracing.
Definition: HttpTrace.h:391
The methods in the HttpTrace class are re-entrant, except for HttpTrace::setFLushCallback and HttpTrace::setBufSize. These two functions, if used, must be called at system startup.
|
| static void | setFLushCallback (HttpTrace_Flush fcb) |
| | The HTTP_TRACE compile time macro adds the trace library to the Barracuda library, but the trace functions will have no effect if you do not provide a callback function. More...
|
| |
| static void | vprintf (int prio, const char *fmt, va_list argList) |
| | Write data to the trace buffer. More...
|
| |
| static void | printf (int prio, const char *fmt,...) |
| | Write data to the trace buffer. More...
|
| |
| static void | write (int prio, const char *buf, int len=-1) |
| | Write data to the trace buffer. More...
|
| |
| static int | setPrio (int prio) |
| | Set the trace message priority filter. More...
|
| |
| static BufPrint * | getWriter () |
| | Get and lock the trace BufPrint object. More...
|
| |
| static void | releaseWriter (void) |
| | Release the trace. More...
|
| |
| static void | setRequest (bool cmd) |
| | Enable or disable request-line tracing. More...
|
| |
| static void | setRequestHeaders (bool cmd) |
| | If enabled, the web-server dumps the content of the request header to the trace buffer. More...
|
| |
| static void | setResponseHeaders (bool cmd) |
| | If enabled, the web-server dumps the content of the response header to the trace buffer. More...
|
| |
| static void | setResponseBody (bool cmd) |
| | If enabled, the web-server dumps the content of the response body to the trace buffer. More...
|
| |
| static void | setHttp11State (bool cmd) |
| | If enabled, prints the status for each active client connection of the internal "HTTP 1.1 persistent connection" state machine to the trace buffer. More...
|
| |
| static void | setReqBufOverflow (bool cmd) |
| | Prints "ReqBufOverflow" if enabled and the HttpRequest buffer overflows. More...
|
| |
| static int | setBufSize (int size) |
| | Set trace buffer size. More...
|
| |
|
static void | flush () |
| | Force a flush on data in trace buffer; i.e., call the flush callback.
|
| |
|
static bool | isRequestSet () |
| | Returns true if request-line tracing is enabled.
|
| |
|
static bool | isRequestHeadersSet () |
| | Returns true if request-header tracing is enabled.
|
| |
|
static bool | isResponseHeadersSet () |
| | Returns true if response-header tracing is enabled.
|
| |
|
static bool | isResponseBodySet () |
| | Returns true if response-body tracing is enabled.
|
| |
|
static bool | isHttp11StateSet () |
| | Returns true if HTTP/1.1 connection-state tracing is enabled.
|
| |