► |  | Web Server: HTTP Server

1 | Dispatching Server
2 | Dispatchers
3 | Launching Servers
4 | Web Servers
5 | Internal APIs
6 | Troubleshooting and Tips
| Index

▼ | 2 | Dispatchers

2.1 | General
2.2 | Mapping URLs to Paths
2.3 | Sequencing
2.4 | Timeouts
2.5 | Lifting Procedures
2.6 | Filtering Requests
2.7 | Procedure Invocation upon Request
2.8 | Logging
2.9 | Password Protection
2.10 | Virtual Hosts
2.11 | Serving Files
2.12 | Serving Servlets
2.13 | Statistics
2.14 | Limiting Requests

On this page:

format-req/ c
paren-format
extended-format
apache-default-format
log-format/ c
log-format->format
make

top ← prev up next →

#### 2.8`` Logging

(require web-server/dispatchers/dispatch-log)

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

> > value

> > format-req/c : contract?

Equivalent to (-> request? string?).

> > value

> > paren-format : format-req/c

Formats a request 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)))

> > value

> > extended-format : format-req/c

Formats a request 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))))

> > value

> > apache-default-format : format-req/c

Formats a request like Apache’s default. However, Apache’s default includes information about the response to a request, which this function does not have access to, so it defaults the last two fields to 200 and 512.

> > value

> > log-format/c : contract?

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

> > procedure

> > (log-format->format id) → format-req/c

> id : log-format/c

Maps 'parenthesized-default to paren-format, 'extended to extended-format, and 'apache-default to apache-default-format.

> > procedure

> > (make [#:format format #:log-path log-path]) → dispatcher/c

> format : format-req/c = paren-format
> log-path : path-string? = "log"

Logs requests to log-path by using format to format the requests. Then invokes next-dispatcher.
top ← prev up next →