From 83993d7739231668fed0a8f3135c4895ec82b2a6 Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Thu, 20 Nov 2025 12:56:53 +0000 Subject: [PATCH] zilch-cli-ninja: Use the logger Change-Id: I4cfcd8495d05500b14ba4c9b39726bc86a6a6964 --- cli/zilch-ninja.scm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cli/zilch-ninja.scm b/cli/zilch-ninja.scm index 13b7106..71acbe8 100644 --- a/cli/zilch-ninja.scm +++ b/cli/zilch-ninja.scm @@ -28,7 +28,18 @@ (when (assoc 'help options) (print-help #f)) +;; Set up the logger. +(define (set-print-logs val) #f) +(let ((prev-error-handler (current-exception-handler))) (current-exception-handler (lambda data (set-print-logs #t) (apply prev-error-handler data)))) +(when (terminal-port? (current-error-port)) + (let-values (((new-out new-err statusbar-set-print-logs logger) (statusbar-logger (current-output-port) (current-error-port) (assoc 'print-build-logs options)))) + (current-output-port new-out) + (current-error-port new-err) + (set! set-print-logs statusbar-set-print-logs) + (*logger* logger))) + (when (null? args) + (set-print-logs #t) (print-help "No subcommand")) ;; Flags passed to the nix daemon: @@ -70,7 +81,7 @@ (when (eq? (car c) 'project) (let loop ((rewrites (ninja-build-config-rewrites config))) (cond - ((null? rewrites) (error "Subproject not found" (cdr c))) + ((null? rewrites) (set-print-logs #t) (error "Subproject not found" (cdr c))) ((string=? (caar rewrites) (cdr c)) (set! config (cdar rewrites))) (else (loop (cdr rewrites))))))) options)