aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2024-04-26 18:59:08 -0600
committerMatthew Holt <[email protected]>2024-04-26 18:59:08 -0600
commitba5811467a4a6f4c173ffc333e5ca2de4d5148f6 (patch)
tree300194281bfb64036ffc26198f50affaf2c1be42
parent1b9042bcdd03b4edea8447355f970e1c5aff8c10 (diff)
downloadcaddy-ba5811467a4a6f4c173ffc333e5ca2de4d5148f6.tar.gz
caddy-ba5811467a4a6f4c173ffc333e5ca2de4d5148f6.zip
events: Add debug log
-rw-r--r--modules/caddyevents/app.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/caddyevents/app.go b/modules/caddyevents/app.go
index 1684cfd2a..902c6d842 100644
--- a/modules/caddyevents/app.go
+++ b/modules/caddyevents/app.go
@@ -261,7 +261,9 @@ func (app *App) Emit(ctx caddy.Context, eventName string, data map[string]any) E
return nil, false
})
- logger.Debug("event", zap.Any("data", e.Data))
+ logger = logger.With(zap.Any("data", e.Data))
+
+ logger.Debug("event")
// invoke handlers bound to the event by name and also all events; this for loop
// 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
default:
}
+ // this log can be a useful sanity check to ensure your handlers are in fact being invoked
+ // (see https://github.com/mholt/caddy-events-exec/issues/6)
+ logger.Debug("invoking subscribed handler",
+ zap.String("subscribed_to", eventName),
+ zap.Any("handler", handler))
+
if err := handler.Handle(ctx, e); err != nil {
aborted := errors.Is(err, ErrAborted)