[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/02: substitutes: Log the failing queries.
From: |
guix-commits |
Subject: |
02/02: substitutes: Log the failing queries. |
Date: |
Sat, 7 Jan 2023 08:27:43 -0500 (EST) |
mothacehe pushed a commit to branch master
in repository guix.
commit 8b665a4ff3aa01d689fdbdd8e6757c13e2180507
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Wed Dec 28 15:19:29 2022 +0100
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(+)
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 @@
(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 @@ if file doesn't exist, and the narinfo otherwise."
(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))