14 lines
392 B
Go
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)
|
|
}
|