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, and the .NET log levels.
It excludes log4j's and Ruby's FATAL level, Python's CRITICAL, and .NET's
Critical level. The recommended behavior on a FATAL, CRITICAL, or
Critical error is to emit an Error-level error and to trap.
Another similar API is the POSIX syslog function. LOG_EMERG, LOG_ALERT,
and LOG_CRIT have no corresponding level, because WASI programs don't have
visibility into how their own errors affect "the system" as a whole. A plain
Error level should be used, optionally with a trap if it's desirable to
halt execution. And LOG_NOTICE and LOG_INFO both correspond to Info,
because other 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