[BUGFIX] Fixes use of config setting for loglevel

This commit is contained in:
hendrik 2026-02-05 00:52:43 +01:00
parent b3f77a7a5b
commit dacd084497
2 changed files with 13 additions and 4 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ test-pages
app.log
.idea
/schema/
.cargo

View File

@ -16,9 +16,17 @@ extern "C" {
}
#[wasm_bindgen]
pub fn load_context() {
wasm_logger::init(wasm_logger::Config::new(log::Level::Info));
return;
pub fn set_log_level(str: &str) {
let log_lv = match str {
"error" => log::Level::Error,
"warn" => log::Level::Warn,
"info" => log::Level::Info,
"debug" => log::Level::Debug,
"trace" => log::Level::Trace,
_ => log::Level::Info,
};
wasm_logger::init(wasm_logger::Config::new(log_lv));
}
#[wasm_bindgen]
@ -63,7 +71,7 @@ pub async fn add_schema_file(to_get: &str) -> Result<JsValue, JsValue> {
#[wasm_bindgen]
pub fn add_logger() {
wasm_logger::init(wasm_logger::Config::new(log::Level::Info));
set_log_level(option_env!("RUST_LOG").unwrap_or("info"));
log::info!("Logger initialized - fire fetch command for page schema");
wasm_bindgen_futures::spawn_local(async {
load_schema_file_from_url("page.schema.yml");