diff options
Diffstat (limited to 'src/scm/webid-oidc/program.scm')
-rw-r--r-- | src/scm/webid-oidc/program.scm | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/scm/webid-oidc/program.scm b/src/scm/webid-oidc/program.scm index 4d431da..d4b98fe 100644 --- a/src/scm/webid-oidc/program.scm +++ b/src/scm/webid-oidc/program.scm @@ -16,6 +16,7 @@ (define-module (webid-oidc program) #:use-module (webid-oidc errors) + #:use-module (webid-oidc server log) #:use-module (webid-oidc reverse-proxy) #:use-module (webid-oidc identity-provider) #:use-module (webid-oidc client) @@ -62,8 +63,12 @@ (define cache-http-get (with-cache #:http-get http-get-with-log)) -(define (handler-with-log complete-corresponding-source handler) +(define (handler-with-log log-file error-file complete-corresponding-source handler) (lambda (request request-body) + (when log-file + (prepare-log-file log-file)) + (when error-file + (prepare-error-file error-file)) (call/ec (lambda (return) (with-exception-handler @@ -484,14 +489,6 @@ If you find a bug, then please send a report to ~a. help-sym) (exit 1)) (install-suspendable-ports!) - (when (option-ref options log-file-sym #f) - (set-current-output-port - (stubs:open-output-file* (option-ref options log-file-sym #f))) - (setvbuf (current-output-port) 'none)) - (when (option-ref options error-file-sym #f) - (set-current-error-port - (stubs:open-output-file* (option-ref options error-file-sym #f))) - (setvbuf (current-error-port) 'none)) (let ((command (car rest)) (non-options (cdr rest))) (cond @@ -507,6 +504,8 @@ If you find a bug, then please send a report to ~a. (exit 1)) (run-server (handler-with-log + (option-ref options log-file-sym #f) + (option-ref options error-file-sym #f) complete-corresponding-source (make-reverse-proxy #:server-uri server-name @@ -553,7 +552,10 @@ If you find a bug, then please send a report to ~a. #:current-time current-time #:http-get cache-http-get))) (run-server - (handler-with-log complete-corresponding-source handler) + (handler-with-log + (option-ref options log-file-sym #f) + (option-ref options error-file-sym #f) + complete-corresponding-source handler) 'http (list #:port port))))) ((equal? command (G_ "command-line|command|client-service")) @@ -579,7 +581,10 @@ If you find a bug, then please send a report to ~a. #:client-name client-name #:client-uri client-uri))) (run-server - (handler-with-log complete-corresponding-source handler) + (handler-with-log + (option-ref options log-file-sym #f) + (option-ref options error-file-sym #f) + complete-corresponding-source handler) 'http (list #:port port))))) ((equal? command (G_ "command-line|command|server")) @@ -641,6 +646,8 @@ If you find a bug, then please send a report to ~a. (create-root server-name subject) (run-server (handler-with-log + (option-ref options log-file-sym #f) + (option-ref options error-file-sym #f) complete-corresponding-source (lambda (request request-body) (let ((path (uri-path (request-uri request)))) |