#log #logging #wasm-component #log-messages #wasi

no-std wasi-logger

A log::Log implementation for WASM components backed by the wasi:logging/logging WIT interface

3 releases

0.1.2 May 22, 2024
0.1.1 May 16, 2024
0.1.0 Apr 21, 2024

#1145 in WebAssembly

Download history 102/week @ 2024-07-22 87/week @ 2024-07-29 92/week @ 2024-08-05 86/week @ 2024-08-12 123/week @ 2024-08-19 165/week @ 2024-08-26 76/week @ 2024-09-02 120/week @ 2024-09-09 54/week @ 2024-09-16 103/week @ 2024-09-23 68/week @ 2024-09-30 128/week @ 2024-10-07 16/week @ 2024-10-14 96/week @ 2024-10-21 62/week @ 2024-10-28 104/week @ 2024-11-04

295 downloads per month
Used in llama-core

MIT/Apache

14KB
141 lines

CI Status MSRV Latest Version Rust Doc Crate Rust Doc Main

wasi-logger

wasi-logger provides a Logger implementing the log::Log logging API, which is backed by the wasi:logging/logging WIT interface.

Usage

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");
}

Features

  • The kv feature transitively enables log/kv and includes the key-value pairs in a log record in the log message.

License

Licensed under either of

at your option.

Contribution

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.

Funding

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.

Dependencies

~7.5MB
~133K SLoC