From 88be978e876fee376c45606d3c7d420961977898 Mon Sep 17 00:00:00 2001 From: Rob Meng Date: Tue, 11 Jul 2023 22:50:36 -0400 Subject: [PATCH] allow logging in JS (#283) tested with `RUST_LOG=info npm test` --- rust/ffi/node/Cargo.toml | 1 + rust/ffi/node/src/lib.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/rust/ffi/node/Cargo.toml b/rust/ffi/node/Cargo.toml index 6b281c0b..f49a6da4 100644 --- a/rust/ffi/node/Cargo.toml +++ b/rust/ffi/node/Cargo.toml @@ -21,3 +21,4 @@ tokio = { version = "1.23", features = ["rt-multi-thread"] } neon = {version = "0.10.1", default-features = false, features = ["channel-api", "napi-6", "promise-api", "task-api"] } object_store = { workspace = true, features = ["aws"] } async-trait = "0" +env_logger = "0" diff --git a/rust/ffi/node/src/lib.rs b/rust/ffi/node/src/lib.rs index 232cbaa3..7fe18e4b 100644 --- a/rust/ffi/node/src/lib.rs +++ b/rust/ffi/node/src/lib.rs @@ -82,6 +82,9 @@ where fn runtime<'a, C: Context<'a>>(cx: &mut C) -> NeonResult<&'static Runtime> { static RUNTIME: OnceCell = OnceCell::new(); + static LOG: OnceCell<()> = OnceCell::new(); + + LOG.get_or_init(|| env_logger::init()); RUNTIME.get_or_try_init(|| Runtime::new().or_else(|err| cx.throw_error(err.to_string()))) }