lang: Add debug-log feature flag (#240)
This commit is contained in:
parent
6f89079332
commit
71873a77a3
|
@ -21,6 +21,8 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
|
||||||
let name = &s.ident;
|
let name = &s.ident;
|
||||||
let ty = &s.raw_field.ty;
|
let ty = &s.raw_field.ty;
|
||||||
quote! {
|
quote! {
|
||||||
|
#[cfg(feature = "debug-log")]
|
||||||
|
::solana_program::log::sol_log(stringify!(#name));
|
||||||
let #name: #ty = anchor_lang::Accounts::try_accounts(program_id, accounts)?;
|
let #name: #ty = anchor_lang::Accounts::try_accounts(program_id, accounts)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,9 +40,13 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
|
||||||
let name = &f.typed_ident();
|
let name = &f.typed_ident();
|
||||||
match f.is_init {
|
match f.is_init {
|
||||||
false => quote! {
|
false => quote! {
|
||||||
|
#[cfg(feature = "debug-log")]
|
||||||
|
::solana_program::log::sol_log(stringify!(#name));
|
||||||
let #name = anchor_lang::Accounts::try_accounts(program_id, accounts)?;
|
let #name = anchor_lang::Accounts::try_accounts(program_id, accounts)?;
|
||||||
},
|
},
|
||||||
true => quote! {
|
true => quote! {
|
||||||
|
#[cfg(feature = "debug-log")]
|
||||||
|
::solana_program::log::sol_log(stringify!(#name));
|
||||||
let #name = anchor_lang::AccountsInit::try_accounts_init(program_id, accounts)?;
|
let #name = anchor_lang::AccountsInit::try_accounts_init(program_id, accounts)?;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue