Fixed incorrect event handler registration in two plugins: - Statistics plugin was calling Step instead of Stop on StopEvent, preventing statistics from being printed at the end of execution. - Logs plugin was listening to StopEvent instead of StepEvent, causing it to only log once at the end instead of on each step.
26 lines
494 B
Go
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.StepEvent, plugin.Step)
|
|
|
|
return plugin
|
|
}
|
|
|
|
func (t *Logs) Step() {
|
|
stringified := lambda.Stringify(*t.process.Expression)
|
|
t.logger.Info("reduction", "tree", stringified)
|
|
}
|