allow logging in JS (#283)

tested with `RUST_LOG=info npm test`
This commit is contained in:
Rob Meng
2023-07-11 22:50:36 -04:00
committed by GitHub
parent 98b12caa06
commit 88be978e87
2 changed files with 4 additions and 0 deletions

View File

@@ -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"

View File

@@ -82,6 +82,9 @@ where
fn runtime<'a, C: Context<'a>>(cx: &mut C) -> NeonResult<&'static Runtime> {
static RUNTIME: OnceCell<Runtime> = 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())))
}