Skip to content

Improve logging from webhook #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions templates/Caddyfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ https://{{ caddy.addresses.webhook }} {
http://{{ caddy.addresses.webhook }} {
{% endif %}

# Include access logs when an error occurs, since we mask any internal errors
# from escaping to the outside world, but otherwise don't log.
log {
output discard
}
log errors {
no_hostname
}

root * {{ caddy.site_dir }}

# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#delivery-headers
Expand All @@ -41,6 +50,9 @@ http://{{ caddy.addresses.webhook }} {
# Don't leak out internal problems.
@error status 4xx 5xx
handle_response @error {
log_name errors
log_append api_error_code {rp.status_code}
log_append api_error_text {rp.status_text}
error 400
}
}
Expand All @@ -51,6 +63,9 @@ http://{{ caddy.addresses.webhook }} {
# Don't leak out internal problems.
@error status 4xx 5xx
handle_response @error {
log_name errors
log_append api_error_code {rp.status_code}
log_append api_error_text {rp.status_text}
error 503
}
}
Expand Down