A proposed WebAssembly System Interface API.
WASI-logging is currently in Phase 1.
- Dan Gohman
The Phase 4 Adancement Criteria for this API are not yet defined.
- Introduction
- Goals
- Non-goals
- API walk-through
- Detailed design discussion
- Stakeholder Interest & Feedback
- References & acknowledgements
WASI Logging is a WASI API for emitting log messages.
The primary goal of WASI logging is to be a simple logging API usable as a stderr destination in commands and as a logging output in headless programs.
WASI Logging is not aiming to be a general-purpose output stream, with support for error reporting or asynchronous operation.
There are two main use cases.
The logging API can be used to log simple messages:
log(Level::Info, "fyi", "The program is running");
The logging API can be used as an output for a command-style stderr.
log(Level::Info, "stderr", "Message printed to stderr in a command");
The log levels are similar to those of log4j, the Rust log crate, the Python log levels, the Ruby log levels, the .NET log levels, the Go zap library log levels, and the Go zerolog library levels.
Another similar API is the POSIX syslog
function. LOG_EMERG
and LOG_ALERT
have no corresponding levels, because WASI programs don't have visibility into
how their own errors affect "the system" as a whole. A Critical
level should
be used instead, optionally with a trap if it's desirable to halt execution.
Similarly, LOG_NOTICE
and LOG_INFO
both correspond to Info
, because most
of the popular systems don't make a distinction between these levels.
Currently the context parameter is an uninterpreted string, because it's the simplest thing that works for now. It may evolve into something else though.
TODO before entering Phase 3.
Many thanks for valuable feedback and advice from:
- Luke Wagner