Crates.io | wasi-logger |
lib.rs | wasi-logger |
version | 0.1.2 |
source | src |
created_at | 2024-04-21 11:32:02.263751 |
updated_at | 2024-05-22 04:56:50.418289 |
description | A `log::Log` implementation for WASM components backed by the `wasi:logging/logging` WIT interface. |
homepage | |
repository | https://github.com/juntyr/wasi-logger |
max_upload_size | |
id | 1215315 |
size | 31,063 |
wasi-logger
provides a Logger
implementing the log::Log
logging API, which is backed by the wasi:logging/logging
WIT interface.
To use the Logger
as a logger, it first needs to be installed once in the top-level WASM component using Logger::install
, e.g. in a main
function, a ctor, or using a std::sync::OnceLock
. Remember to also set the global logging max level using log::set_max_level
to ensure that log entries created with log::log!
and others are actually recorded.
#[macro_use]
extern crate log;
extern crate wasi_logger;
fn main() {
wasi_logger::Logger::install().expect("failed to install wasi_logger::Logger");
log::set_max_level(log::LevelFilter::Info);
error!("Something went really wrong");
info!("This is good to know");
debug!("This message is not recorded as the trace level is currently disabled");
}
kv
feature transitively enables log/kv
and includes the key-value pairs in a log record in the log message.Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
wasi-logger
has been developed as part of ESiWACE3, the third phase of the Centre of Excellence in Simulation of Weather and Climate in Europe.
Funded by the European Union. This work has received funding from the European High Performance Computing Joint Undertaking (JU) under grant agreement No 101093054.