Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 13:15 UTC
events: Add debug log
Matthew Holt committed
Apr 26, 2024 at 18:59 UTC
ba5811467a4a6f4c173ffc333e5ca2de4d5148f6
1 file changed
+9
-1
modules/caddyevents/app.go
+9
-1
@@ -261,7 +261,9 @@ func (app *App) Emit(ctx caddy.Context, eventName string, data map[string]any) E
261
return nil, false
262
})
263
264
- logger.Debug("event", zap.Any("data", e.Data))
264
+ logger = logger.With(zap.Any("data", e.Data))
265
+
266
+ logger.Debug("event")
267
268
// invoke handlers bound to the event by name and also all events; this for loop
269
// iterates twice at most: once for the event name, once for "" (all events)
@@ -282,6 +284,12 @@ func (app *App) Emit(ctx caddy.Context, eventName string, data map[string]any) E
284
default:
285
}
286
287
+ // this log can be a useful sanity check to ensure your handlers are in fact being invoked
288
+ // (see https://github.com/mholt/caddy-events-exec/issues/6)
289
+ logger.Debug("invoking subscribed handler",
290
+ zap.String("subscribed_to", eventName),
291
+ zap.Any("handler", handler))
292
+
293
if err := handler.Handle(ctx, e); err != nil {
294
aborted := errors.Is(err, ErrAborted)
295