The Hook API provides a set of functions in the namespace
trace which write output to the
xrpld log file when xrpld is configured with the trace log-level. These functions, generally speaking, allow you to see the value of variables, buffers and otherwise trace the execution and state of a Hook at runtime.
At time of writing there is no interactive Hook Debugger. You must use the trace functions.
trace functions are available in the Hooks API
|What it does
|Print a utf-8 message, followed by a user-specified buffer (this last optionally as hex.)
|Print a utf-8 message, followed by an integer.
|Print a utf-8 message, followed by an XFL Floating point number.
|Print a utf-8 message, followed by the serialized contents of a slot.
The following code will print a single trace line then accept the Originating Transaction.
int64_t hook(int64_t reserved)
trace_num(SBUF("A number"), 10);
An example of the log-line produced by
xrpld when a payment is sent out of or into the Hook Account:
2021-Apr-13 13:59:11.083700726 UTC View:TRC
A number 10
The above appears in the log as all-one-line, but split here for visibility.
The Hooks Public Testnet V2 is the perfect place to test your Hooks.
A breakdown of the log format appears in the table below
|2021-Apr-13 13:59:11.083700726 UTC View:TRC
xrpld's prefix to the log line
|This is a trace initiated by the Hook itself not some other information about the Hook. Other information is available on tags
|The first account in the square brackets is the Hook Account.
|The second account in the square brackets is the Originating Account.
|This is the message the Hook was told to deliver before the trace payload
|This is the trace payload
Xrpldproduces a lot of output. It is therefore generally advisible to grep logs for the account/s you are interested in.
For example use:
tail -f log | grep HookTrace | grep <account>
Updated almost 2 years ago