On this page:
format-reqresp/  c
paren-format
extended-format
apache-default-format
combined-log-format
log-format/  c
log-format->format
make

2.9 Logging🔗ℹ

The web-server/dispatchers/dispatch-logresp module defines a dispatcher constructor for transparent logging of requests and responses.

Formats a request and a response by:
(format
 "~s\n"
 (list 'from (request-client-ip req)
       'to (request-host-ip req)
       'for (url->string (request-uri req))
       'at (date->string
            (seconds->date (current-seconds)) #t)
       'code (response-code resp)))

Formats a request and a response by:
(format
 "~s\n"
 `((client-ip ,(request-client-ip req))
   (host-ip ,(request-host-ip req))
   (referer
    ,(let ([R (headers-assq*
               #"Referer"
               (request-headers/raw req))])
       (if R
           (header-value R)
           #f)))
   (uri ,(url->string (request-uri req)))
   (time ,(current-seconds))
   (code ,(response-code resp))))

Formats a request and a response like Apache’s default. However, Apache’s default includes information about the size of the object returned to the client, which this function does not have access to, so it defaults the last field to -.

Formats a request and a response to approximate the Combined Log Format. As this function does not have access to the size of the object returned to the client, it defaults the field to -.

Equivalent to (symbols 'parenthesized-default 'extended 'apache-default 'combined).

procedure

(log-format->format id)  format-reqresp/c

  id : log-format/c
Maps 'parenthesized-default to paren-format, 'extended to extended-format, 'apache-default to apache-default-format, and 'combined to combined-log-format

procedure

(make [#:format format    
  #:log-path log-path]    
  dispatcher)  dispatcher/c
  format : (or/c log-format/c format-reqresp/c) = paren-format
  log-path : (or/c path-string? output-port?) = "log"
  dispatcher : dispatcher/c
If dispatcher is successfully dispatched, logs requests and responses (without the body information) to log-path, which can be either a filepath or an output-port?, using format to format the requests and responses (or just requests if format only accepts one argument). If format is a symbol, a log formatter will be tacitly made using log-format->format.

Added in version 1.12 of package web-server-lib.