This answer helped me to find get_transaction()
method of solana_client::rpc_client::RpcClient
, so to obtain logs of the transaction one needs to do the following:
let signature = rpc_client.send_and_confirm_transaction(&tx)?;
let transaction_with_meta = rpc_client.get_transaction(
&signature,
UiTransactionEncoding::Json,
)?;
// transaction itself can be extracted this way:
let transaction = transaction_with_meta.transaction;
This struct contains 3 fields: meta
, transaction
and version
.
transaction
is what was actually sent to the network (reсent blockhash, instructions, accounts, signatures and so on)
meta
contains different meta-information (see this), logs are among it.
// Type annotation here is just for verbosity
let logs:Vec<String> = transaction
.meta
.log_messages
.expect("There are no logs!");