* open-logfile returns null-output-port if logfile cannot be opened for writing
* No output to stderr anymore. Output now goes to syslog. If syslogging is disabled, bad luck.
This commit is contained in:
parent
2f0397483b
commit
ed0679bb85
|
@ -39,9 +39,17 @@
|
|||
(define server/version "Scheme-Underground/1.0")
|
||||
(define server/protocol "HTTP/1.0")
|
||||
|
||||
; default: no logging
|
||||
; initialized by init-http-log!
|
||||
;; default: no logging
|
||||
;; initialized by init-http-log!
|
||||
|
||||
;; CLF-logging
|
||||
;; if enabled, it will look like this:
|
||||
;; (lambda req reply-code)
|
||||
(define http-log (lambda a #f)) ; makes logging in CLF
|
||||
|
||||
;; syslogging
|
||||
;; if enabled, it will look like this:
|
||||
;; (lambda (level fmt . args)
|
||||
(define http-syslog (lambda a #f)) ; makes syslog
|
||||
(define *http-syslog?* #f) ; trigger used to avoid
|
||||
; unnecessary computations
|
||||
|
@ -52,8 +60,10 @@
|
|||
(set! *http-log-port* port))
|
||||
|
||||
(define (init-http-log! options)
|
||||
(init-http-port-log! (httpd-options-logfile options))
|
||||
(init-http-syslog! (httpd-options-syslog? options)))
|
||||
;; syslog has to be initialized befor CLF-logging
|
||||
;; because it may generate syslog-messages
|
||||
(init-http-syslog! (httpd-options-syslog? options))
|
||||
(init-http-port-log! (httpd-options-logfile options)))
|
||||
|
||||
(define (init-http-port-log! logfile)
|
||||
(let ((logport
|
||||
|
@ -64,13 +74,13 @@
|
|||
logfile)
|
||||
((eq? logfile #f) ; no logging demanded
|
||||
#f)
|
||||
; unexpected value of logfile; we'll use (current-error-port) instead
|
||||
; unexpected value of logfile;
|
||||
(else
|
||||
(format (current-error-port)
|
||||
"[httpd] Warning: Logfile was not specified correctly (given: ~S).~%
|
||||
Logging now to stderr.\n"
|
||||
logfile)
|
||||
(current-error-port)))))
|
||||
(http-syslog
|
||||
(syslog-level warning)
|
||||
"[httpd] Warning: Logfile was not specified correctly (given: ~S).~% No CLF logging."
|
||||
logfile)
|
||||
(make-null-output-port)))))
|
||||
|
||||
(if logfile ; if logging was specified, set up the logger
|
||||
(let ((http-log-lock (make-lock)))
|
||||
|
@ -130,8 +140,8 @@
|
|||
(define (open-logfile logfile)
|
||||
(with-errno-handler*
|
||||
(lambda (errno packet)
|
||||
(format (current-error-port)
|
||||
"[httpd] Warning: An error occured while opening ~S for writing (~A).~%Send signal USR1 when the problem is fixed.~%"
|
||||
(http-syslog (syslog-level warning)
|
||||
"[httpd] Warning: An error occured while opening ~S for writing (~A).~%Send signal USR1 when the problem is fixed.~%"
|
||||
logfile
|
||||
(car packet))
|
||||
(make-null-output-port))
|
||||
|
@ -608,7 +618,6 @@
|
|||
(if message (format out "<P>~%~a~%" message)))))
|
||||
|
||||
((= reply-code http-reply/internal-error)
|
||||
(format (current-error-port) "ERROR: ~A~%" message)
|
||||
(http-syslog (syslog-level error) "internal-error: ~A" message)
|
||||
(if html-ok?
|
||||
(begin
|
||||
|
|
Loading…
Reference in New Issue