[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] gwl/ui: Check for log-events configuration
From: |
Olivier Dion |
Subject: |
[PATCH 1/3] gwl/ui: Check for log-events configuration |
Date: |
Mon, 6 Jun 2022 15:48:58 -0400 |
Some GWL sub-commands might not accept the log-events switch.
This results in returning `#f' from `(%config 'log-events)'
Fix this by checking that 'log-events was configured. Also memoize the result.
---
gwl/ui.scm | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/gwl/ui.scm b/gwl/ui.scm
index 35bd127..bfe20a9 100644
--- a/gwl/ui.scm
+++ b/gwl/ui.scm
@@ -17,6 +17,8 @@
#:use-module (gwl config)
#:use-module (gwl errors)
#:use-module (guix colors)
+ #:use-module ((guix memoization)
+ #:select (mlambdaq))
#:use-module (srfi srfi-26)
#:use-module (ice-9 format)
#:export (G_
@@ -63,11 +65,16 @@
(format (current-error-port) "~a"
(prefix-color prefix))))
+(define print?
+ (mlambdaq (type)
+ (let ((log-events (%config 'log-events)))
+ (and log-events
+ (or (member 'all log-events)
+ (member type log-events))
+ #t))))
+
(define (log-event type . message)
- (define print?
- (or (member 'all (%config 'log-events))
- (member type (%config 'log-events))))
- (when print?
+ (when (print? type)
(case type
((error)
(print-diagnostic-prefix (G_ "error: ") #:colors %error-color))
--
2.36.1
[PATCH 1/3] gwl/ui: Check for log-events configuration,
Olivier Dion <=