log

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

func Default() *slog.Logger

Default returns the package-level logger. Use this from any function that doesn't carry a context.Context.

func FromContext

func FromContext(ctx context.Context) *slog.Logger

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 SetupDiscard

func SetupDiscard()

SetupDiscard silences logging entirely. For use in tests.

func SetupRPC

func SetupRPC(h slog.Handler)

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).

func With

func With(ctx context.Context, l *slog.Logger) context.Context

With returns a context with the given logger attached. The logger is what FromContext will return for any descendant context.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL