Macro near_sdk::log

source ·
macro_rules! log {
    ($arg:expr) => { ... };
    ($($arg:tt)*) => { ... };
}
Expand description

Helper macro to log a message through env::log_str. This macro can be used similar to the std::format macro in most cases.

This differs from std::format because instead of generating a string, it will log the utf8 bytes as a log through env::log_str.

The logged message will get persisted on chain.

§Example use

use near_sdk::log;

log!("test");
let world: &str = "world";
log!(world);
log!("Hello {}", world);
log!("x = {}, y = {y}", 10, y = 30);