mirror of
https://github.com/caddyserver/caddy.git
synced 2026-09-15 15:17:25 -04:00
App.Emit does a fair amount of work before it can discover that no handler is bound: it derives three loggers, one of which formats the event's UUID even when debug logging is off, and registers a replacer callback. Only then does it reach "shortcut if event not bound at all". Some events are emitted on every TLS handshake -- CertMagic emits tls_get_certificate as the first statement of GetCertificateWithContext -- so on a server with no events configuration that work runs per handshake and is discarded every time. Return early when neither the event's name nor the catch-all is bound and debug logging is off, which are exactly the conditions under which nothing can observe the event. caddy.NewEvent still runs, so the returned Event is unchanged for callers. Benchmarks are included; measurements are in the pull request.