1 unstable release

new 0.1.0 Nov 10, 2024

#119 in #log-messages

Download history 99/week @ 2024-11-08

99 downloads per month
Used in pinocchio-log

Apache-2.0

9KB
105 lines

pinocchio-log-macro

Companion log! macro for pinocchio-log. It automates the creation of a Logger object to log a message. It support a limited subset of the format! syntax. The macro parses the format string at compile time and generates the calls to a Logger object to generate the corresponding formatted message.

Usage

The macro works very similar to solana-program msg! macro.

To output a simple message (static &str):

use pinocchio_log::log

log!("a simple log");

To ouput a formatted message:

use pinocchio_log::log

let amount = 1_000_000_000;
log!("transfer amount: {}", amount);

Since a Logger size is statically determined, messages are limited to 200 length by default. When logging larger messages, it is possible to increase the logger buffer size:

use pinocchio_log::log

let very_long_message = "...";
log!(500, "message: {}", very_long_message);

License

The code is licensed under the Apache License Version 2.0

Dependencies

~1.5MB
~37K SLoC