Module solana_program::log

source ·
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_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_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

Print a string to the log.
Print 64-bit values represented as hexadecimal to the log.
Print the remaining compute units available to the program.
Print some slices as base64.
Print the hexadecimal representation of the program’s input parameters.
Print the hexadecimal representation of a slice.