TSDebug

Traffic Server Debugging APIs.

Synopsis

#include <ts/ts.h>

void TSDebug(const char * tag, const char * format, ...) InkAPI.cc line 6769
void TSError(const char * tag, const char * format, ...) InkAPI.cc line 386
int TSIsDebugTagSet(const char * tag) InkAPI.cc line 6749
void TSDebugSpecific(int debug_flag, const char * tag, const char * format, ...) InkAPI.cc line 6755
void TSHttpTxnDebugSet(TSHttpTxn txnp, int on) InkAPI.cc line 5722
void TSHttpSsnDebugSet(TSHttpSsn ssn, int on) ProxyClientSession.h line 5736
int TSHttpTxnDebugGet(TSHttpTxn txnp) InkAPI.cc line 5729
int TSHttpSsnDebugGet(TSHttpSsn ssn) InkAPI.cc line 5743
const char* TSHttpServerStateNameLookup(TSServerState state) InkAPI.cc line 8611
const char* TSHttpHookNameLookup(TSHttpHookID hook) InkAPI.cc line 8617
const char* TSHttpEventNameLookup(TSEvent event) InkAPI.cc line 8623
void TSAssert(expression) ts.h line 268
void TSReleaseAssert(expression) ts.h line 265

Description

TSError() is similar to printf() except that instead of writing the output to the C standard output, it writes output to the Traffic Server error log.

TSDebug() is the same as TSError() except that it only logs the debug message if the given debug tag is enabled. It writes output to the Traffic Server debug log.

TSIsDebugTagSet() returns non-zero if the given debug tag is enabled.

In debug mode, TSAssert Traffic Server to prints the file name, line number and expression, and then aborts. In release mode, the expression is not removed but the effects of printing an error message and aborting are. TSReleaseAssert prints an error message and aborts in both release and debug mode.

TSDebugSpecific() emits a debug line even if the debug tag is turned off, as long as debug flag is enabled. This can be used in conjunction with TSHttpTxnDebugSet(), TSHttpSsnDebugSet(), TSHttpTxnDebugGet() and TSHttpSsnDebugGet() to enable debugging on specific session and transaction objects.

TSHttpServerStateNameLookup(), TSHttpHookNameLookup() and TSHttpEventNameLookup() converts the respective internal state to a string representation. This can be useful in debugging (TSDebug()), logging and other types notifications.

Examples

This example uses TSDebugSpecific() to log a message when a specific debugging flag is enabled:

#include <ts/ts.h>

// Produce information about a hook receiving an event
TSDebug(PLUGIN_NAME, "Entering hook=%s, event=%s",
        TSHttpHookNameLookup(hook), TSHttpEventNameLookup(event));

// Emit debug message if "tag" is enabled or the txn debug
// flag is set.
TSDebugSpecifc(TSHttpTxnDebugGet(txn), "tag" ,
        "Hello World from transaction %p", txn);

See also

TSAPI(3ts), printf(3)