From 38c378e98aaedc563dded43a6a212d9239a74516 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 28 Dec 2023 09:34:51 +0000 Subject: Avoid calling display for logging As I'm getting encoding-error (put-char conversion to port encoding failed) errors from it sometimes. It doesn't happen at all, then suddenly it seems to happen continuously. --- guix-build-coordinator/coordinator.scm | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'guix-build-coordinator') diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm index 7ac0853..bc1dbae 100644 --- a/guix-build-coordinator/coordinator.scm +++ b/guix-build-coordinator/coordinator.scm @@ -30,11 +30,13 @@ #:use-module (ice-9 vlist) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) + #:use-module (ice-9 binary-ports) #:use-module (ice-9 format) #:use-module (ice-9 atomic) #:use-module (ice-9 control) #:use-module (ice-9 threads) #:use-module (ice-9 exceptions) + #:use-module (rnrs bytevectors) #:use-module (web uri) #:use-module (web http) #:use-module (oop goops) @@ -137,6 +139,23 @@ (lambda (build-coordinator port) (display "#" port))) +(define-class () + (port #:init-value #f #:accessor port #:init-keyword #:port)) + +(define-method (emit-log (self ) str) + (if (port self) + (put-bytevector (port self) + (string->utf8 str)))) + +(define-method (flush-log (self )) + (if (port self) + (force-output (port self)))) + +(define-method (close-log! (self )) + (if (port self) + (close-port (port self))) + (set! (port self) #f)) + (define %known-hooks '(build-submitted build-started @@ -371,7 +390,7 @@ hooks)) (let* ((lgr (make )) - (port-log (make + (port-log (make #:port (current-output-port) #:formatter (lambda (lvl time str) @@ -397,6 +416,9 @@ (pid-file #f) (trigger-build-allocation? #t) (parallel-hooks '())) + ;; The logger assumes this + (set-port-encoding! (current-output-port) "UTF-8") + (with-exception-handler (lambda (exn) (simple-format #t "failed enabling core dumps: ~A\n" exn)) -- cgit v1.2.3