Adding generalization of log to serve/servlet

This commit is contained in:
Jay McCarthy 2011-08-08 11:44:34 -06:00
parent a11734d990
commit f0e52b80df
2 changed files with 7 additions and 4 deletions

View File

@ -166,7 +166,7 @@ Like always, you don't even need to save the file.
[#:ssl-key ssl-key (or/c false/c path-string?) (and ssl? (build-path server-root-path "private-key.pem"))] [#:ssl-key ssl-key (or/c false/c path-string?) (and ssl? (build-path server-root-path "private-key.pem"))]
[#:log-file log-file (or/c false/c path-string?) #f] [#:log-file log-file (or/c false/c path-string?) #f]
[#:log-format log-format log-format/c 'apache-default]) [#:log-format log-format (or/c log-format/c format-req/c) 'apache-default])
void]{ void]{
This sets up and starts a fairly default server instance. This sets up and starts a fairly default server instance.
@ -211,7 +211,7 @@ Like always, you don't even need to save the file.
Web Server is used instead. Of course, if a path is given, then it overrides this behavior. Web Server is used instead. Of course, if a path is given, then it overrides this behavior.
If @racket[log-file] is given, then it used to log requests using @racket[log-format] as the format. Allowable formats If @racket[log-file] is given, then it used to log requests using @racket[log-format] as the format. Allowable formats
are those allowed by @racket[log-format->format]. are those allowed by @racket[log-format->format]. If @racket[log-format] is a function, it is used directly to render the log entry.
If @racket[connection-close?] is @racket[#t], then every connection is closed after one If @racket[connection-close?] is @racket[#t], then every connection is closed after one
request. Otherwise, the client decides based on what HTTP version it uses. request. Otherwise, the client decides based on what HTTP version it uses.

View File

@ -64,7 +64,7 @@
#:servlet-path string? #:servlet-path string?
#:servlet-regexp regexp? #:servlet-regexp regexp?
#:log-file (or/c false/c path-string?) #:log-file (or/c false/c path-string?)
#:log-format log:log-format/c) #:log-format (or/c log:log-format/c log:format-req/c))
. ->* . . ->* .
void)]) void)])
@ -145,7 +145,10 @@
[log-format 'apache-default]) [log-format 'apache-default])
(define (dispatcher sema) (define (dispatcher sema)
(dispatcher-sequence (dispatcher-sequence
(and log-file (log:make #:format (log:log-format->format log-format) (and log-file (log:make #:format
(if (symbol? log-format)
(log:log-format->format log-format)
log-format)
#:log-path log-file)) #:log-path log-file))
(and quit? (filter:make #rx"^/quit$" (quit-server sema))) (and quit? (filter:make #rx"^/quit$" (quit-server sema)))
(dispatch/servlet (dispatch/servlet