logging
Direction: guest calls into the host through it · Capability: none (pure data / dispatch) · Worlds: completion-source-plugin (imports), config-plugin (imports), context-plugin (imports), dashboard-plugin (imports), decorations-plugin (imports), error-parser-plugin (imports), events-plugin (imports), help-plugin (imports), keymap-plugin (imports), language-plugin (imports), media-plugin (imports), modes-plugin (imports), multibuffer-view-plugin (imports), picker-source-plugin (imports), plugin (imports), plugin-manager-plugin (imports), scanned-excerpt-source-plugin (imports), sign-plugin (imports), theme-plugin (imports), transient-source-plugin (imports)
Guest→host structured logging (plugin observability Layer 2, design docs/dev/architecture/plugin-observability.md §8). Shaped like wasi:logging/logging so any component-model language calls it with no lattice-specific glue: a guest emits its OWN narrative ("parsing X", "reindexed 40 files") and the host routes each call into the same PluginTracer that carries the boundary trace (Layer 1), tagged by plugin + level, so the guest's intent interleaves with the host's observed behaviour in one *plugin-trace* buffer.
Language-agnostic and off the hot path: logging is an async-linker import (never wired into the sync grammar seam), so it cannot touch the keystroke path. context is a free-form category the guest chooses (e.g. a subsystem name); an empty string is fine. Fire-and-forget — no reply, the host cannot fail the call.
Functions (1)
log
log: func(level: level, context: string, message: string)
Emit one log line. level gates it against the plugin's trace verbosity (the same per-plugin gate the boundary trace uses); context is a free-form category; message is the line. Dropped silently when the plugin's gate is below level — exactly like a boundary-trace record.
Example — Log at several levels, each with a context string the host renders as the category · crates/lattice-plugin-host/tests/fixtures/logging-guest/src/lib.rs
// Distinct levels + contexts so the host test can assert routing, level
// mapping, and the context→category rendering. `info`/`warn` are kept at
// the default gate; `debug`/`trace` only when the plugin is raised.
logging::log(Level::Info, "boot", "logging guest activated");
logging::log(Level::Warn, "index", "reindex found 2 stale entries");
logging::log(Level::Debug, "detail", "walked 40 files in 3ms");
logging::log(Level::Error, "", "a context-less error line");
Types (1)
enum level
enum level {
trace,
debug,
info,
warn,
error,
critical,
}
Severity, mirroring wasi:logging. critical folds into the host's error trace level (the tracer has no separate critical tier); off is not a log level (it is a gate-only value on the host side).