Files
lingniu-vehicle-ingest/go/vehicle-gateway/internal/observability/logger.go
2026-07-01 21:43:16 +08:00

14 lines
392 B
Go

package observability
import (
"log/slog"
"os"
)
// NewLogger returns a JSON logger with a stable service field so ECS logs from
// different Go processes can be filtered without relying on container names.
func NewLogger(service string) *slog.Logger {
handler := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{AddSource: true})
return slog.New(handler).With("service", service)
}