Changing log cache to regular variable

svn: r640
This commit is contained in:
Jay McCarthy 2005-08-23 22:24:59 +00:00
parent ef55cd3242
commit 00b2750368

View File

@ -246,24 +246,24 @@
; 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 (make-parameter #f)]) [log-p #f])
(lambda (host-ip client-ip method uri host) (lambda (host-ip client-ip method uri host)
(call-with-semaphore (call-with-semaphore
outsem outsem
(lambda () (lambda ()
(with-handlers ([exn? (lambda (e) (log-p #f))]) (with-handlers ([exn? (lambda (e) (set! log-p #f))])
(unless (and (log-p) (file-exists? log-path)) (unless (and log-p (file-exists? log-path))
(unless (eq? (log-p) #f) (unless (eq? log-p #f)
(close-output-port (log-p))) (close-output-port log-p))
(log-p (open-output-file log-path 'append)) (set! log-p (open-output-file log-path 'append))
(file-stream-buffer-mode (log-p) 'line)) (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
(when (log-p) (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))))))))
; ignore-log : sym str -> str str sym url str -> str ; ignore-log : sym str -> str str sym url str -> str
(define (ignore-log log-format log-path) void) (define (ignore-log log-format log-path) void)