0))))))))))
(define (with-output-log filename thunk)
- (call-with-output-file filename
- (lambda (out)
- (dynamic-wind
- (lambda () unspecific)
- (lambda () (with-output-to-port out thunk))
- (lambda ()
- (flush-output out)
- (set-file-modes! filename #o444))))))
+ (let ((value
+ (call-with-current-continuation
+ (lambda (throw)
+ (call-with-output-file filename
+ (lambda (out)
+ (bind-condition-handler (list condition-type:serious-condition
+ condition-type:simple-condition)
+ (named-lambda (log-condition-handler condition)
+ (write-condition-report condition out)
+ (newline out)
+ (close-port out)
+ (throw condition))
+ (lambda ()
+ (with-output-to-port out thunk)))))
+ #f))))
+ (set-file-modes! filename #o444)
+ (if (condition? value)
+ (error value))))
(define (log-timestamp)
(log "# "(universal-time->local-time-string (get-universal-time))"\n"))