From 8b665a4ff3aa01d689fdbdd8e6757c13e2180507 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Wed, 28 Dec 2022 15:19:29 +0100 Subject: substitutes: Log the failing queries. * guix/substitutes.scm (%debug?): New variable. (handle-narinfo-response): Log the failing queries if the %debug? parameter is set. --- guix/substitutes.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'guix') diff --git a/guix/substitutes.scm b/guix/substitutes.scm index 9014cf61ec..edff84aac3 100644 --- a/guix/substitutes.scm +++ b/guix/substitutes.scm @@ -90,6 +90,16 @@ (define %narinfo-cache-directory (string-append %state-directory "/substitute/cache")) (string-append (cache-directory #:ensure? #f) "/substitute"))) +(define %debug? + ;; Enable debug mode by setting the GUIX_SUBSTITUTE_DEBUG environmnent + ;; variable. + (make-parameter + (getenv "GUIX_SUBSTITUTE_DEBUG"))) + +(define-syntax-rule (debug fmt args ...) + (when (%debug?) + (format #t fmt args ...))) + (define (narinfo-cache-file cache-url path) "Return the name of the local file that contains an entry for PATH. The entry is stored in a sub-directory specific to CACHE-URL." @@ -224,6 +234,13 @@ (define (handle-narinfo-response request response port result) (let* ((path (uri-path (request-uri request))) (hash-part (basename (string-drop-right path 8)))) ;drop ".narinfo" + ;; Log the failing queries and indicate if it failed because the + ;; narinfo is being baked. + (let ((baking? + (assoc-ref (response-headers response) 'x-baking))) + (debug "could not fetch ~a~a ~a~a~%" + url path code + (if baking? " (baking)" ""))) (if len (get-bytevector-n port len) (read-to-eof port)) -- cgit v1.2.3