aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-12-28 09:34:51 +0000
committerChristopher Baines <mail@cbaines.net>2023-12-28 09:34:51 +0000
commit38c378e98aaedc563dded43a6a212d9239a74516 (patch)
treef43660a8992039c166a2d2dd1e2379e8aa033db8
parent9ec4c59c2ca094138b9ee639856990b755c428d2 (diff)
downloadbuild-coordinator-38c378e98aaedc563dded43a6a212d9239a74516.tar
build-coordinator-38c378e98aaedc563dded43a6a212d9239a74516.tar.gz
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.
-rw-r--r--guix-build-coordinator/coordinator.scm24
1 files changed, 23 insertions, 1 deletions
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 "#<build-coordinator>" port)))
+(define-class <custom-port-log> (<log-handler>)
+ (port #:init-value #f #:accessor port #:init-keyword #:port))
+
+(define-method (emit-log (self <custom-port-log>) str)
+ (if (port self)
+ (put-bytevector (port self)
+ (string->utf8 str))))
+
+(define-method (flush-log (self <custom-port-log>))
+ (if (port self)
+ (force-output (port self))))
+
+(define-method (close-log! (self <custom-port-log>))
+ (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 <logger>))
- (port-log (make <port-log>
+ (port-log (make <custom-port-log>
#: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))