16 lines
350 B
Go
16 lines
350 B
Go
package logging
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"io"
|
||
|
|
"log/slog"
|
||
|
|
)
|
||
|
|
|
||
|
|
// New creates the process logger. Callers provide the sink so tests and the
|
||
|
|
// command entry point do not need to share global logging state.
|
||
|
|
func New(w io.Writer) *slog.Logger {
|
||
|
|
if w == nil {
|
||
|
|
w = io.Discard
|
||
|
|
}
|
||
|
|
return slog.New(slog.NewJSONHandler(w, &slog.HandlerOptions{Level: slog.LevelInfo}))
|
||
|
|
}
|