Documentation
¶
Overview ¶
Package log provides a thin convention layer on top of log/slog for the infinite.pm Go toolchain (cmd/md-embed, cmd/ipm-rpc, and the shared pkg/ipm/* packages).
Why a wrapper at all when log/slog already exists?
- We want one place that knows how to switch between a text handler (for CLI invocations and developer terminals) and a JSON handler (for the LSP server, where the host editor reads structured logs).
- Shared packages should not import VS Code- or LSP-specific code; the wrapper lets cmd/ipm-rpc inject a handler that publishes log records as `window/logMessage` notifications without leaking that dependency into pkg/ipm/*.
- Tests need a no-op default that doesn't pollute test output.
Default (when no init function is called): records at WARN+ go to stderr in text form; INFO/DEBUG are dropped. CLIs override with SetupCLI() to get human-readable output; ipm-rpc will install its own handler that forwards records to the LSP client.
Per an earlier design note.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
Default returns the package-level logger. Use this from any function that doesn't carry a context.Context.
func FromContext ¶
FromContext returns the context-scoped logger if one is attached, else Default(). Use this from LSP handlers that thread context down into pkg/ipm/* — each request can have its own attributes (method, id, file) attached up front so every log record from the request inherits them.
func SetupCLI ¶
func SetupCLI(verbose, quiet bool)
SetupCLI configures the package-level logger for command-line use: human-readable text on stderr, level controlled by verbose. Use this from cmd/md-embed and any future CLI's main() before parsing arguments.
func SetupRPC ¶
SetupRPC configures the package-level logger to forward records via the given handler. cmd/ipm-rpc installs an adapter that wraps each record into a `window/logMessage` LSP notification; pkg/ipm/* callers never see the LSP dependency.
Pass nil to fall back to the default (WARN+ on stderr).
Types ¶
This section is empty.