TSDebug - traffic Server Debugging APIs
Contents
Copyright
2025, dev@trafficserver.apache.org
9.2 May 22, 2025 TSDEBUG(3ts)
Diags.Log
The following methods print to diags.log with expected reactions as a coordinated outcome of Traffic
Server, Traffic Manager, AuTest, CI, and your log monitoring service/dashboard (e.g. Splunk)
┌───────────────┬─────────────────────────────┬────────────────┬───────────┬────────────┐
│ API │ Purpose │ TrafficManager │ AuTest+CI │ LogMonitor │
├───────────────┼─────────────────────────────┼────────────────┼───────────┼────────────┤
│ TSStatus() │ basic information │ │ │ │
├───────────────┼─────────────────────────────┼────────────────┼───────────┼────────────┤
│ TSNote() │ significant │ │ │ │
│ │ information │ │ │ │
├───────────────┼─────────────────────────────┼────────────────┼───────────┼────────────┤
│ TSWarning() │ concerning │ │ │ track │
│ │ information │ │ │ │
├───────────────┼─────────────────────────────┼────────────────┼───────────┼────────────┤
│ TSError() │ operational failure │ │ FAIL │ review │
├───────────────┼─────────────────────────────┼────────────────┼───────────┼────────────┤
│ TSFatal() │ recoverable crash │ restart │ FAIL │ review │
├───────────────┼─────────────────────────────┼────────────────┼───────────┼────────────┤
│ TSAlert() │ significant crash │ restart │ FAIL │ ALERT │
├───────────────┼─────────────────────────────┼────────────────┼───────────┼────────────┤
│ TSEmergency() │ unrecoverable,misconfigured │ EXIT │ FAIL │ ALERT │
└───────────────┴─────────────────────────────┴────────────────┴───────────┴────────────┘
NOTE:TSFatal(), TSAlert(), and TSEmergency() can be called within TSPluginInit(), such that Traffic Server
can be shutdown promptly when the plugin fails to initialize properly.
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);
Name
TSDebug - traffic Server Debugging APIs
See Also
TSAPI(3ts), printf(3)
Synopsis
#include <ts/ts.h>
voidTSStatus(constchar*format,...)voidTSNote(constchar*format,...)voidTSWarning(constchar*format,...)voidTSError(constchar*format,...)voidTSFatal(constchar*format,...)voidTSAlert(constchar*format,...)voidTSEmergency(constchar*format,...)voidTSDebug(constchar*tag,constchar*format,...)intTSIsDebugTagSet(constchar*tag)voidTSDebugSpecific(intdebug_flag,constchar*tag,constchar*format,...)voidTSHttpTxnDebugSet(TSHttpTxntxnp,inton)voidTSHttpSsnDebugSet(TSHttpSsnssn,inton)intTSHttpTxnDebugGet(TSHttpTxntxnp)intTSHttpSsnDebugGet(TSHttpSsnssn)constchar*TSHttpServerStateNameLookup(TSServerStatestate)constchar*TSHttpHookNameLookup(TSHttpHookIDhook)constchar*TSHttpEventNameLookup(TSEventevent)TSAssert(...)TSReleaseAssert(...)Trafficserver.Out
TSDebug() logs the debug message only if the given debug tag is enabled. It writes output to the Traffic
Server debug log through stderr.
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.
