* insert missing *http-log?* variable

* minor format changing to CLF-log entries
This commit is contained in:
interp 2002-04-02 11:34:53 +00:00
parent ea3615a633
commit 75970e8842
1 changed files with 13 additions and 14 deletions

View File

@ -39,11 +39,11 @@
(define server/version "Scheme-Underground/1.0") (define server/version "Scheme-Underground/1.0")
(define server/protocol "HTTP/1.0") (define server/protocol "HTTP/1.0")
;;; Configurable Variables ; default: no logging
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define http-log (lambda a #f)) ; makes logging in CLF
(define http-syslog (lambda a #f)) ; makes syslog
(define http-log (lambda a #f)) (define *http-syslog?* #f) ; trigger used to avoid
(define http-syslog (lambda a #f)) ; unnecessary computations
(define (init-http-log! options) (define (init-http-log! options)
(init-http-port-log! (httpd-options-logfile options)) (init-http-port-log! (httpd-options-logfile options))
@ -80,7 +80,7 @@
(if logfile ; if logging was specified, set up the logger (if logfile ; if logging was specified, set up the logger
(set! http-log (make-http-log-proc logport))))) (set! http-log (make-http-log-proc logport)))))
; alternative-clause: default values of *http-log?* and http-log ; alternative-clause: default values of *http-syslog?* and http-log
(define (init-http-syslog! syslog?) (define (init-http-syslog! syslog?)
(if syslog? (if syslog?
@ -121,12 +121,11 @@
(define (make-CLF remote-ip request-type requested-file protocol http-code filesize referer user-agent) (define (make-CLF remote-ip request-type requested-file protocol http-code filesize referer user-agent)
(format #f "~A - - ~A ~S ~A ~A ~S ~S~%" (format #f "~A - - ~A ~S ~A ~A ~S ~S~%"
(or remote-ip "-") (or remote-ip "-")
(format-date "[~d/~b/~Y:~H:~M:~S]" (date)) (format-date "[~d/~b/~Y:~H:~M:~S +0000]" (date)) ; +0000 as we don't know
(string-join (list request-type requested-file protocol)) (string-join (list "/" request-type requested-file protocol))
; Unfortunately, we first split the request line into ; Unfortunately, we first split the request line into
; method/request-type etc. and put it together here. ; method/request-type etc. and put it together here.
; Files conform to CLF are expected to print the original line. ; Files conform to CLF are expected to print the original line.
; We loose here, as the initial `/' is missing in our log.
(or http-code "-") (or http-code "-")
(or filesize "-") (or filesize "-")
(or referer "") (or referer "")
@ -171,7 +170,7 @@
(lambda () (lambda ()
(socket-address->internet-address (socket-remote-address sock))) (socket-address->internet-address (socket-remote-address sock)))
(lambda (host-address service-port) (lambda (host-address service-port)
(if (and rate-limiter *http-log?*) (if (and rate-limiter *http-syslog?*)
(http-syslog (syslog-level info) "<~a>~a: concurrent request #~a~%" (http-syslog (syslog-level info) "<~a>~a: concurrent request #~a~%"
(pid) (pid)
(format-internet-host-address host-address) (format-internet-host-address host-address)
@ -186,13 +185,13 @@
(socket:outport sock) (socket:outport sock)
(set-port-buffering (current-input-port) bufpol/none) (set-port-buffering (current-input-port) bufpol/none)
(process-toplevel-request sock host-address options))) (process-toplevel-request sock host-address options)))
(if *http-log?* (if *http-syslog?*
(http-syslog (syslog-level debug) "<~a>~a [closing]~%" (http-syslog (syslog-level debug) "<~a>~a [closing]~%"
(pid) (pid)
(format-internet-host-address host-address))) (format-internet-host-address host-address)))
(with-fatal-error-handler (with-fatal-error-handler
(lambda (c decline) (lambda (c decline)
(if *http-log?* (if *http-syslog?*
(http-syslog (syslog-level notice) "<~a>~a [error closing (~a)]~%" (http-syslog (syslog-level notice) "<~a>~a [error closing (~a)]~%"
(pid) (pid)
(format-internet-host-address host-address) (format-internet-host-address host-address)
@ -200,7 +199,7 @@
(close-socket sock)) (close-socket sock))
(if rate-limiter (if rate-limiter
(rate-limit-close rate-limiter)) (rate-limit-close rate-limiter))
(if *http-log?* (if *http-syslog?*
(http-syslog (syslog-level info) "<~a>~a [closed]~%" (http-syslog (syslog-level info) "<~a>~a [closed]~%"
(pid) (pid)
(format-internet-host-address host-address))))))))) (format-internet-host-address host-address)))))))))
@ -318,7 +317,7 @@
(let ((line (read-crlf-line))) (let ((line (read-crlf-line)))
; (display line (current-error-port)) (newline (current-error-port)) ; (display line (current-error-port)) (newline (current-error-port))
;; Blat out some logging info. ;; Blat out some logging info.
(if *http-log?* (if *http-syslog?*
(call-with-values (call-with-values
(lambda () (lambda ()
(socket-address->internet-address (socket-remote-address sock))) (socket-address->internet-address (socket-remote-address sock)))