TSDebug¶
Traffic Server Debugging APIs.
概要¶
#include <ts/ts.h>
- 
void 
TSStatus(const char *format, ...)¶ 
- 
void 
TSNote(const char *format, ...)¶ 
- 
void 
TSWarning(const char *format, ...)¶ 
- 
void 
TSError(const char *format, ...)¶ 
- 
void 
TSFatal(const char *format, ...)¶ 
- 
void 
TSAlert(const char *format, ...)¶ 
- 
void 
TSEmergency(const char *format, ...)¶ 
- 
void 
TSDebug(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( ... ) 
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  | 
|---|---|---|---|---|
basic information  | 
||||
significant information  | 
||||
concerning information  | 
track  | 
|||
operational failure  | 
FAIL  | 
review  | 
||
recoverable crash  | 
restart  | 
FAIL  | 
review  | 
|
significant crash  | 
restart  | 
FAIL  | 
ALERT  | 
|
unrecoverable,misconfigured  | 
EXIT  | 
FAIL  | 
ALERT  | 
注釈
TSFatal(), TSAlert(), and TSEmergency() can be called within
TSPluginInit(), such that Traffic Server can be shutdown promptly when
the plugin fails to initialize properly.
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() は与えられたデバッグ :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)