Expand description

Logging utilities for Rust-based Solana programs.

Logging is the main mechanism for getting debugging information out of running Solana programs, and there are several functions available for doing so efficiently, depending on the type of data being logged.

The most common way to emit logs is through the msg! macro, which logs simple strings, as well as formatted strings.

Logs can be viewed in multiple ways:

  • The solana logs command displays logs for all transactions executed on a network. Note though that transactions that fail during pre-flight simulation are not displayed here.
  • When submitting transactions via RpcClient, if Rust’s own logging is active then the solana_rpc_client crate logs at the “debug” level any logs for transactions that failed during simulation. If using env_logger these logs can be activated by setting RUST_LOG=solana_rpc_client=debug.
  • Logs can be retrieved from a finalized transaction by calling RpcClient::get_transaction.
  • Block explorers may display logs.

While most logging functions are defined in this module, Pubkeys can also be efficiently logged with the Pubkey::log function.

Functions§