Browse Source

lang: Add debug-log feature flag (#240)

Lucio M. Tato 4 years ago
parent
commit
71873a77a3
1 changed files with 6 additions and 0 deletions
  1. 6 0
      lang/syn/src/codegen/accounts.rs

+ 6 - 0
lang/syn/src/codegen/accounts.rs

@@ -21,6 +21,8 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
                     let name = &s.ident;
                     let ty = &s.raw_field.ty;
                     quote! {
+                        #[cfg(feature = "debug-log")]
+                        ::solana_program::log::sol_log(stringify!(#name));
                         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();
                         match f.is_init {
                             false => quote! {
+                                #[cfg(feature = "debug-log")]
+                                ::solana_program::log::sol_log(stringify!(#name));
                                 let #name = anchor_lang::Accounts::try_accounts(program_id, accounts)?;
                             },
                             true => quote! {
+                                #[cfg(feature = "debug-log")]
+                                ::solana_program::log::sol_log(stringify!(#name));
                                 let #name = anchor_lang::AccountsInit::try_accounts_init(program_id, accounts)?;
                             },
                         }