Files
lambda/internal/plugins/debug.go
M.V. Hutz 6b946fb5dc refactor: replace string-based emitter with type-safe generic event system
Refactors the event emitter system from string-based messages to a
type-safe generic implementation using typed events. Consolidates
separate tracker packages into a unified plugins architecture.

Changes:
- Replace Emitter with BaseEmitter[E comparable] using generics
- Add Event type with StartEvent, StepEvent, and StopEvent constants
- Create Listener[E] interface with BaseListener implementation
- Consolidate explanation, performance, and statistics trackers into
  internal/plugins package
- Simplify main CLI by using plugin constructors instead of manual
  event subscription
- Add Items() iterator method to Set for idiomatic range loops
2026-01-13 19:27:56 -05:00

26 lines
494 B
Go

package plugins
import (
"log/slog"
"git.maximhutz.com/max/lambda/internal/engine"
"git.maximhutz.com/max/lambda/pkg/lambda"
)
type Logs struct {
logger *slog.Logger
process *engine.Engine
}
func NewLogs(logger *slog.Logger, process *engine.Engine) *Logs {
plugin := &Logs{logger, process}
process.On(engine.StopEvent, plugin.Step)
return plugin
}
func (t *Logs) Step() {
stringified := lambda.Stringify(*t.process.Expression)
t.logger.Info("reduction", "tree", stringified)
}