Plug.AccessLog.Formatter

Log message formatter.

Source

Summary

format(format, conn)

Formats a log message

Functions

format(format, conn)

Specs:

Formats a log message.

The :default format is :clf.

The following formatting directives are available:

  • %% - Percentage sign
  • %B - Size of response in bytes. Outputs “0” when no bytes are sent.
  • %b - Size of response in bytes. Outputs “-“ when no bytes are sent.
  • %h - Remote hostname
  • %{VARNAME}i - Header line sent by the client
  • %l - Remote logname
  • %r - First line of HTTP request
  • %>s - Response status code
  • %t - Time the request was received in the format [10/Jan/2015:14:46:18 +0100]
  • %u - Remote user
  • %U - URL path requested (without query string)
  • %v - Server name

Note for %B and %b: To determine the size of the response the “Content-Length” (exact case match required for now!) will be inspected and, if available, returned unverified. If the header is not present the response body will be inspected using byte_size/1.

Note for %h: The hostname will always be the ip of the client.

Note for %l: Always a dash (“-“).

Note for %r: For now the http version is always logged as “HTTP/1.1”, regardless of the true http version.

Source