feat: add RELP handler for reliable log delivery to rsyslog (closes #5) #6

Open
clawbot wants to merge 2 commits from clawbot/simplelog:feat/relp-handler into main
Showing only changes of commit b20bc2bd4e - Show all commits

View File

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