Guide

Logging

Logging

Whiplash logs nothing of its own on the request path. What goes wrong reaches OTP Logger the ordinary way:

  • a handler that raises produces an OTP crash report for its connection (on HTTP/1) or its worker (on HTTP/2 and HTTP/3);
  • supervisors report children that fail and restart, at Error;
  • at Info, supervisors also report every child they start: Whiplash's own at start-up, and with TLS one small supervisor per connection, which OTP's ssl starts.

So any OTP Logger handler sees Whiplash's failures, and the application chooses how to format and where to collect them. Set the threshold with pooka_otp:

Pooka
module main

import pooka/http
import pooka/otp.{LogLevel}
import whiplash

main() {
  // Notice keeps start-up and TLS progress reports out; failures still show.
  otp.set_log_level(LogLevel.Notice)
  let assert Ok(_) = whiplash.start(whiplash.options(8080), fn(_) { http.text(200, "ok") })
  otp.sleep_forever()
}

To log your own events with request context, log where the work happens: a handler, a streaming producer and an upload handler each run in their own process (on HTTP/2 and HTTP/3, every request does), so process-scoped logging context must be set there.

An access log costs time on every request; Whiplash does not write one. Log what matters to your application, where it happens.