Enable env_logger in the C API (#1737)
This commit ensures that `env_logger` and `RUST_LOG` are configured to work with the C API.
This commit is contained in:
@@ -11,6 +11,16 @@ wasmtime_c_api_macros::declare_own!(wasm_engine_t);
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
||||
// Enable the `env_logger` crate since this is as good a place as any to
|
||||
// support some "top level initialization" for the C API. Almost all support
|
||||
// should go through this one way or another, so this ensures that
|
||||
// `RUST_LOG` should work reasonably well.
|
||||
//
|
||||
// Note that we `drop` the result here since this fails after the first
|
||||
// initialization attempt. We don't mind that though because this function
|
||||
// can be called multiple times, so we just ignore the result.
|
||||
drop(env_logger::try_init());
|
||||
|
||||
Box::new(wasm_engine_t {
|
||||
engine: HostRef::new(Engine::default()),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user