TSDebug¶
Traffic Server Debugging APIs.
概要¶
#include <ts/ts.h>
-
void
TSDebug(const char *tag, const char *format, ...)¶
-
void
TSError(const char *tag, const char *format, ...)¶
-
int
TSIsDebugTagSet(const char *tag)¶
-
void
TSDebugSpecific(int debug_flag, const char *tag, const char *format, ...)¶
-
const char *
TSHttpServerStateNameLookup(TSServerState state)¶
-
const char *
TSHttpHookNameLookup(TSHttpHookID hook)¶
-
void TSAssert( ... )
-
void TSReleaseAssert( ... )
解説¶
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() は与えられたデバッグ tag が有効化されている場合にのみログメッセージを出力する点を除いて TSError() と同じです。
TSIsDebugTagSet() は与えられたデバッグ :arg:`tag`が有効化されている場合に非ゼロを返します。
デバッグモードでは、TSAssert は Traffic Server にファイル名、行番号、式を出力させ、処理を中断します。リリースモードでは、式の出力は残りますが、エラーメッセージの出力と処理の中断は行われません。TSReleaseAssert はリリースモードとデバッグモードのどちらでもエラーメッセージの出力と処理の中断を行います。
TSDebugSpecific() はデバッグ tag がオフにされていてもデバッグフラグが有効化されてさえいればデバッグ行を出力します。これは特定のセッションとトランザクションオブジェクトでデバッグを有効化するために TSHttpTxnDebugSet() 、TSHttpSsnDebugSet() 、TSHttpTxnDebugGet() 、TSHttpSsnDebugGet() と組み合わせて使用されることがあります。
TSHttpServerStateNameLookup() 、TSHttpHookNameLookup() そして TSHttpEventNameLookup() はそれぞれの内部状態を文字列表現に変換します。これはデバッグ、ロギング、その他のタイプの通知を行う際に便利です。
例¶
この例は特定のデバッグフラグが有効になっている場合にメッセージをログに出力するために TSDebugSpecific() を使用しています。
#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);
参照¶
TSAPI(3ts), printf(3)