fix: replace log.Println with fmt.Fprintln in JSONHandler to prevent deadlock
This commit is contained in:
parent
31c9ed52cb
commit
b20bc2bd4e
@ -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
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user