Archived
1
0
Fork 0

status: Don't display download URLs for '--verbosity=1'.

With this change, each substitute occupies a single line of
output (instead of two) when using '-v1', the default for 'guix package'
& co.

* guix/status.scm (print-build-event): Add #:print-urls? and honor it.
(print-build-event/quiet): Pass #:print-urls? #f.
(print-build-event/quiet-with-urls): New procedure.
(logger-for-level): Add case for LEVEL 2.
* doc/guix.texi (Common Build Options): Adjust '--verbosity'
documentation.
This commit is contained in:
Ludovic Courtès 2021-03-21 17:23:40 +01:00
parent 1fa4aff1fb
commit e45ef9a648
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 23 additions and 7 deletions

View file

@ -10264,9 +10264,10 @@ guix-daemon, @option{--timeout}}).
@cindex build logs, verbosity @cindex build logs, verbosity
@item -v @var{level} @item -v @var{level}
@itemx --verbosity=@var{level} @itemx --verbosity=@var{level}
Use the given verbosity @var{level}, an integer. Choosing 0 means that no Use the given verbosity @var{level}, an integer. Choosing 0 means that
output is produced, 1 is for quiet output, and 2 shows all the build log no output is produced, 1 is for quiet output; 2 is similar to 1 but it
output on standard error. additionally displays download URLs; 3 shows all the build log output on
standard error.
@item --cores=@var{n} @item --cores=@var{n}
@itemx -c @var{n} @itemx -c @var{n}

View file

@ -403,10 +403,12 @@ the current build phase."
#:optional (port (current-error-port)) #:optional (port (current-error-port))
#:key #:key
(colorize? (color-output? port)) (colorize? (color-output? port))
(print-urls? #t)
(print-log? #t)) (print-log? #t))
"Print information about EVENT and STATUS to PORT. When COLORIZE? is true, "Print information about EVENT and STATUS to PORT. When COLORIZE? is true,
produce colorful output. When PRINT-LOG? is true, display the build log in produce colorful output. When PRINT-LOG? is true, display the build log in
addition to build events." addition to build events. When PRINT-URLS? is true, display the URL of
substitutes being downloaded."
(define info (define info
(if colorize? (if colorize?
(cute colorize-string <> (color BOLD)) (cute colorize-string <> (color BOLD))
@ -526,9 +528,10 @@ addition to build events."
(format port (info (G_ "substituting ~a...")) item) (format port (info (G_ "substituting ~a...")) item)
(newline port))) (newline port)))
(('download-started item uri _ ...) (('download-started item uri _ ...)
(erase-current-line*) (when print-urls?
(format port (info (G_ "downloading from ~a ...")) uri) (erase-current-line*)
(newline port)) (format port (info (G_ "downloading from ~a ...")) uri)
(newline port)))
(('download-progress item uri (('download-progress item uri
(= string->number size) (= string->number size)
(= string->number transferred)) (= string->number transferred))
@ -602,6 +605,17 @@ addition to build events."
(colorize? (color-output? port))) (colorize? (color-output? port)))
(print-build-event event old-status status port (print-build-event event old-status status port
#:colorize? colorize? #:colorize? colorize?
#:print-urls? #f
#:print-log? #f))
(define* (print-build-event/quiet-with-urls event old-status status
#:optional
(port (current-error-port))
#:key
(colorize? (color-output? port)))
(print-build-event event old-status status port
#:colorize? colorize?
#:print-urls? #t ;show download URLs
#:print-log? #f)) #:print-log? #f))
(define* (build-status-updater #:optional (on-change (const #t))) (define* (build-status-updater #:optional (on-change (const #t)))
@ -787,6 +801,7 @@ evaluate EXP... in that context."
"Return the logging procedure that corresponds to LEVEL." "Return the logging procedure that corresponds to LEVEL."
(cond ((<= level 0) (const #t)) (cond ((<= level 0) (const #t))
((= level 1) print-build-event/quiet) ((= level 1) print-build-event/quiet)
((= level 2) print-build-event/quiet-with-urls)
(else print-build-event))) (else print-build-event)))
(define (call-with-status-verbosity level thunk) (define (call-with-status-verbosity level thunk)