Skip to content

Commit

Permalink
frozen-abi-macro: use log from solana_frozen_abi (#153)
Browse files Browse the repository at this point in the history
* frozen-abi-macro: use `log` from `solana_frozen_abi`

* use private module approach
  • Loading branch information
buffalojoec authored Mar 23, 2024
1 parent 5cfb6e8 commit bfdfc6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions frozen-abi/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn derive_abi_sample_enum_type(input: ItemEnum) -> TokenStream {
#( #attrs )*
impl #impl_generics ::solana_frozen_abi::abi_example::AbiExample for #type_name #ty_generics #where_clause {
fn example() -> Self {
::log::info!(
::solana_frozen_abi::__private::log::info!(
"AbiExample for enum: {}",
std::any::type_name::<#type_name #ty_generics>()
);
Expand Down Expand Up @@ -198,7 +198,7 @@ fn derive_abi_sample_struct_type(input: ItemStruct) -> TokenStream {
#( #attrs )*
impl #impl_generics ::solana_frozen_abi::abi_example::AbiExample for #type_name #ty_generics #where_clause {
fn example() -> Self {
::log::info!(
::solana_frozen_abi::__private::log::info!(
"AbiExample for struct: {}",
std::any::type_name::<#type_name #ty_generics>()
);
Expand Down Expand Up @@ -300,15 +300,15 @@ fn quote_for_test(
let mut hash = digester.finalize();
// pretty-print error
if result.is_err() {
::log::error!("digest error: {:#?}", result);
::solana_frozen_abi::__private::log::error!("digest error: {:#?}", result);
}
result.unwrap();
let actual_digest = format!("{}", hash);
if ::std::env::var("SOLANA_ABI_BULK_UPDATE").is_ok() {
if #expected_digest != actual_digest {
#p!("sed -i -e 's/{}/{}/g' $(git grep --files-with-matches frozen_abi)", #expected_digest, hash);
}
::log::warn!("Not testing the abi digest under SOLANA_ABI_BULK_UPDATE!");
::solana_frozen_abi::__private::log::warn!("Not testing the abi digest under SOLANA_ABI_BULK_UPDATE!");
} else {
if let Ok(dir) = ::std::env::var("SOLANA_ABI_DUMP_DIR") {
assert_eq!(#expected_digest, actual_digest, "Possibly ABI changed? Examine the diff in SOLANA_ABI_DUMP_DIR!: \n$ diff -u {}/*{}* {}/*{}*", dir, #expected_digest, dir, actual_digest);
Expand Down
7 changes: 7 additions & 0 deletions frozen-abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ extern crate solana_frozen_abi_macro;
#[cfg(test)]
#[macro_use]
extern crate serde_derive;

// Not public API. Referenced by macro-generated code.
#[doc(hidden)]
pub mod __private {
#[doc(hidden)]
pub use log;
}

0 comments on commit bfdfc6c

Please sign in to comment.