Better handling of logging, keep the ports around a bit longer

svn: r91
This commit is contained in:
Jay McCarthy 2005-06-12 18:42:09 +00:00
parent 7bb5af8933
commit 329bc78102

View File

@ -244,17 +244,20 @@
; including the major and minor HTTP version numbers ; including the major and minor HTTP version numbers
; to produce a string that is displayed into the log file ; to produce a string that is displayed into the log file
(define (gen-log-message log-format log-path) (define (gen-log-message log-format log-path)
(let ([outsem (make-semaphore 1)]) (let ([outsem (make-semaphore 1)]
[log-p #f])
(lambda (host-ip client-ip method uri host) (lambda (host-ip client-ip method uri host)
(semaphore-wait outsem) (semaphore-wait outsem)
(unless (and log-p (file-exists? log-path))
(set! log-p (open-output-file log-path 'append))
(file-stream-buffer-mode log-p 'line))
; do the display all at once by formating first ; do the display all at once by formating first
(let ([log-p (open-output-file log-path 'append)]) (when log-p
(display (display
(format "~s~n" (format "~s~n"
(list 'from client-ip 'to host-ip 'for (url->string uri) 'at (list 'from client-ip 'to host-ip 'for (url->string uri) 'at
(date->string (seconds->date (current-seconds)) #t))) (date->string (seconds->date (current-seconds)) #t)))
log-p) log-p))
(close-output-port log-p))
(semaphore-post outsem)))) (semaphore-post outsem))))
; ignore-log : sym str -> str str sym url str -> str ; ignore-log : sym str -> str str sym url str -> str