NewMiddleware initializes a new Middleware with the given slog handler initialization function and configuration. newHandler is a function which is invoked on every Work execution to generate a new slog.Handler for a work-specific slog.Logger. It should take an io.Writer and return a slog.Handler o
(newSlogHandler func(w io.Writer) slog.Handler, config *MiddlewareConfig)
| 117 | // func (w *MyWorker) Work(ctx context.Context, job *river.Job[MyArgs]) error { |
| 118 | // Logger(ctx).InfoContext(ctx, "Hello from work") |
| 119 | func NewMiddleware(newSlogHandler func(w io.Writer) slog.Handler, config *MiddlewareConfig) *Middleware { |
| 120 | return &Middleware{ |
| 121 | config: defaultConfig(config), |
| 122 | newSlogHandler: newSlogHandler, |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | // NewMiddlewareCustomContext initializes a new Middleware with the given arbitrary |
| 127 | // context initialization function and configuration. |
searching dependent graphs…