From 329bc781024cf3a45ca8ac9375b3e38fc3b8ae13 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Sun, 12 Jun 2005 18:42:09 +0000 Subject: [PATCH] Better handling of logging, keep the ports around a bit longer svn: r91 --- collects/web-server/configuration.ss | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/collects/web-server/configuration.ss b/collects/web-server/configuration.ss index 74d09bd7a9..ad222c0f2e 100644 --- a/collects/web-server/configuration.ss +++ b/collects/web-server/configuration.ss @@ -244,17 +244,20 @@ ; including the major and minor HTTP version numbers ; to produce a string that is displayed into the log file (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) (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 - (let ([log-p (open-output-file log-path 'append)]) + (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) - (close-output-port log-p)) + log-p)) (semaphore-post outsem)))) ; ignore-log : sym str -> str str sym url str -> str