Redoing the log file port preservation

svn: r98
This commit is contained in:
Jay McCarthy 2005-06-14 13:17:44 +00:00
parent e502ec19b9
commit 4a1b4e44b9

View File

@ -246,23 +246,25 @@
; to produce a string that is displayed into the log file
(define (gen-log-message log-format log-path)
(let ([outsem (make-semaphore 1)]
[log-p #f])
[log-p (make-parameter #f)])
(lambda (host-ip client-ip method uri host)
(semaphore-wait outsem)
(unless (and log-p (file-exists? log-path))
(when log-p
(close-output-port log-p))
(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
(when log-p
(display
(format "~s~n"
(list 'from client-ip 'to host-ip 'for (url->string uri) 'at
(date->string (seconds->date (current-seconds)) #t)))
log-p))
(semaphore-post outsem))))
(call-with-semaphore
outsem
(lambda ()
(with-handlers ([exn? (lambda (e) (log-p #f))])
(unless (and (log-p) (file-exists? log-path))
(unless (eq? (log-p) #f)
(close-output-port (log-p)))
(log-p (open-output-file log-path 'append))
(file-stream-buffer-mode (log-p) 'line))
; do the display all at once by formating first
(when (log-p)
(display
(format "~s~n"
(list 'from client-ip 'to host-ip 'for (url->string uri) 'at
(date->string (seconds->date (current-seconds)) #t)))
(log-p)))))))))
; ignore-log : sym str -> str str sym url str -> str
(define (ignore-log log-format log-path) void)