Files
zeekay 6fe6a46a47 logger: introduce luxfi/log compatibility shim
App callers and plugins want one structured-logging surface that does
not pin them to log/slog. Add a tiny Logger interface and two
implementations:

  - SlogAdapter wraps *slog.Logger so the BatchHandler-backed on-disk
    storage path keeps working; exposes Slog()/Handler() for the
    BatchHandler.SetLevel reload hook and tests that type-assert the
    underlying handler.
  - LuxfiAdapter wraps github.com/luxfi/log.Logger so packages that do
    not own the storage path can run on the canonical Lux logger
    directly.

Both adapters share the geth-style variadic API (msg + "k", v pairs)
that the prior commit already collapsed every call site to, so flipping
core.App.Logger() to return Logger in the next commit is a pure
type-narrowing change for ~95 percent of consumers.
2026-05-15 03:52:54 -07:00

28 lines
1.0 KiB
Go

package logger
// Logger is the small structured-logging surface used by Base and its
// plugins. It deliberately mirrors the geth/luxfi-style variadic API
// (msg + alternating "key", value pairs) so that the same call sites
// work with both backends.
//
// Two implementations live in this package:
//
// - slogAdapter (NewSlog) wraps the standard library's *slog.Logger so
// that the BatchHandler-based on-disk log storage keeps working.
// - luxfiAdapter (NewLuxfi) wraps github.com/luxfi/log.Logger so that
// non-storage consumers run through the canonical Lux logger.
//
// Callers should never type-assert to a concrete implementation. For
// the one historical escape hatch (attaching a custom slog.Handler in
// dev mode and in tests) use SlogHandler on the slog-backed adapter.
type Logger interface {
Debug(msg string, kv ...any)
Info(msg string, kv ...any)
Warn(msg string, kv ...any)
Error(msg string, kv ...any)
// With returns a child logger that prepends the given key/value
// pairs to every record.
With(kv ...any) Logger
}