caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
55.45k stars 3.91k forks source link

logging: Customizable `zapcore.Core` #6381

Closed kkroo closed 2 weeks ago

kkroo commented 3 weeks ago

This change enables support custom caddy.logging.cores that implement zapcore.Core for a sentry event reporting plugin that reports errors and their traces at github.com/kkroo/caddy-sentry

mholt commented 3 weeks ago

Thanks for the contribution!

Since we're teeing, I wonder if multiple cores (a slice of cores) would be worthwhile? Maybe not. Just thinking.

If not, this looks pretty good and we can probably merge it after a quick review. (I think godoc comments will be needed)

francislavoie commented 3 weeks ago

I think an output module is still always needed, right? So I guess you'd want to use output discard along with this maybe, so you're not required to also write to a file or stderr if you want to send it to a module like Sentry? That's my main concern about tee-ing the core.

This also needs Caddyfile support I think, and it would be nice if we could have somekind of mock core module that we can use for testing configuration etc.

kkroo commented 3 weeks ago

Thanks for the feedback, addressing comments .

@mholt An implementation of this interface could chain up multiple cores if needed. I can add the doc strings.

@francislavoie It uses the default logging core. If the user doesn't want additional output output discard