Skip to content

Commit 471195e

Browse files
authored
Merge pull request #42 from QuLogic/webhook-log
Improve logging from webhook
2 parents e8e37f7 + 76760f1 commit 471195e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

templates/Caddyfile.j2

+15
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ https://{{ caddy.addresses.webhook }} {
2222
http://{{ caddy.addresses.webhook }} {
2323
{% endif %}
2424

25+
# Include access logs when an error occurs, since we mask any internal errors
26+
# from escaping to the outside world, but otherwise don't log.
27+
log {
28+
output discard
29+
}
30+
log errors {
31+
no_hostname
32+
}
33+
2534
root * {{ caddy.site_dir }}
2635

2736
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#delivery-headers
@@ -41,6 +50,9 @@ http://{{ caddy.addresses.webhook }} {
4150
# Don't leak out internal problems.
4251
@error status 4xx 5xx
4352
handle_response @error {
53+
log_name errors
54+
log_append api_error_code {rp.status_code}
55+
log_append api_error_text {rp.status_text}
4456
error 400
4557
}
4658
}
@@ -51,6 +63,9 @@ http://{{ caddy.addresses.webhook }} {
5163
# Don't leak out internal problems.
5264
@error status 4xx 5xx
5365
handle_response @error {
66+
log_name errors
67+
log_append api_error_code {rp.status_code}
68+
log_append api_error_text {rp.status_text}
5469
error 503
5570
}
5671
}

0 commit comments

Comments
 (0)