Add tracing log macro that defaults to noop
Change-Id: I5ae1cf9e539a08aa9d820e3bf643a311b2f9080e
This commit is contained in:
parent
2e4279c964
commit
18e52aafe6
|
@ -10,9 +10,10 @@ name = "solitaire"
|
|||
|
||||
[features]
|
||||
client = ["no-entrypoint"]
|
||||
no-entrypoint = []
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
no-entrypoint = []
|
||||
trace = []
|
||||
|
||||
[dependencies]
|
||||
borsh = "0.8.1"
|
||||
|
|
|
@ -3,6 +3,25 @@ use std::ops::{
|
|||
DerefMut,
|
||||
};
|
||||
|
||||
/// A wrapper around Solana's `msg!` macro that is a no-op by default, allows for adding traces
|
||||
/// through the application that can be toggled during tests.
|
||||
#[macro_export]
|
||||
macro_rules! trace {
|
||||
( $($arg:tt)* ) => { $crate::trace_impl!( $($arg)* ) };
|
||||
}
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
#[macro_export]
|
||||
macro_rules! trace_impl {
|
||||
( $($arg:tt)* ) => { solana_program::msg!( $($arg)* ) };
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "trace"))]
|
||||
#[macro_export]
|
||||
macro_rules! trace_impl {
|
||||
( $($arg:tt)* ) => {}
|
||||
}
|
||||
|
||||
/// This is our main codegen macro. It takes as input a list of enum-like variants mapping field
|
||||
/// types to function calls. The generated code produces:
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue