diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..984208beb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +RUST_LOG=info \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index a56851407..b6ad9f0dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2529,7 +2529,7 @@ dependencies = [ [[package]] name = "sargon" -version = "0.7.12" +version = "0.7.13" dependencies = [ "actix-rt", "aes-gcm", diff --git a/Cargo.toml b/Cargo.toml index a1f90e835..4dec7f805 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sargon" -version = "0.7.12" +version = "0.7.13" edition = "2021" build = "build.rs" diff --git a/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/build_information/sargon_build_information_uniffi_fn.rs b/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/build_information/sargon_build_information_uniffi_fn.rs index 40fdf3084..4aa9a272c 100644 --- a/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/build_information/sargon_build_information_uniffi_fn.rs +++ b/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/build_information/sargon_build_information_uniffi_fn.rs @@ -1,3 +1,5 @@ +use std::sync::Once; + use crate::prelude::*; #[uniffi::export] @@ -10,6 +12,25 @@ pub fn new_sargon_build_information_sample_other() -> SargonBuildInformation { SargonBuildInformation::sample_other() } +#[uniffi::export] +pub fn enable_logging_from_rust() { + init_logging() +} + +/// Initializes logging +#[cfg(not(tarpaulin_include))] // actually tricky, since we init logging from other unit tests -> crash. +pub fn init_logging() { + static ONCE: Once = Once::new(); + ONCE.call_once(|| { + let level = log::LevelFilter::Trace; + pretty_env_logger::formatted_builder() + .filter_level(level) + .try_init() + .expect("Should be able to setup a logger."); + info!("Rust: Logger initialized, log level: {:?}", level); + }); +} + #[cfg(test)] mod tests { use super::*;