Merge pull request 'fix: JSONHandler deadlock from recursive log.Println (closes #3)' (#4) from clawbot/simplelog:fix/json-handler-deadlock into main

Reviewed-on: sneak/simplelog#4
This commit is contained in:
Jeffrey Paul 2026-02-08 18:29:55 +01:00
commit 9121da9aae

View File

@ -3,8 +3,9 @@ package simplelog
import (
"context"
"encoding/json"
"log"
"fmt"
"log/slog"
"os"
)
type JSONHandler struct{}
@ -15,7 +16,7 @@ func NewJSONHandler() *JSONHandler {
func (j *JSONHandler) Handle(ctx context.Context, record slog.Record) error {
jsonData, _ := json.Marshal(record)
log.Println(string(jsonData))
fmt.Fprintln(os.Stdout, string(jsonData))
return nil
}