unofficial mirror of gwl-devel@gnu.org
 help / color / mirror / Atom feed
From: Olivier Dion <olivier.dion@polymtl.ca>
To: Olivier Dion <olivier.dion@polymtl.ca>, gwl-devel@gnu.org
Subject: [PATCH 1/3] gwl/ui: Check for log-events configuration
Date: Mon,  6 Jun 2022 15:48:58 -0400	[thread overview]
Message-ID: <20220606194900.27725-1-olivier.dion@polymtl.ca> (raw)
In-Reply-To: <20220603183203.11092-1-olivier.dion@polymtl.ca>

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



  parent reply	other threads:[~2022-06-06 19:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 18:32 [PATCH] gwl/ui: Check for log-events configuration Olivier Dion
2022-06-04 15:00 ` Ricardo Wurmus
2022-06-04 15:10   ` Olivier Dion via
2022-06-06 10:32     ` Ricardo Wurmus
2022-06-06 13:25       ` Olivier Dion via
2022-06-06 18:51         ` Olivier Dion via
2022-06-06 19:48 ` Olivier Dion [this message]
2022-06-06 19:48   ` [PATCH 2/3] gwl/config: Share log-event switch with subcommands Olivier Dion
2022-06-12  9:03     ` Ricardo Wurmus
2022-06-06 19:49   ` [PATCH 3/3] graph: Add output switch Olivier Dion
2022-06-12  9:05     ` Ricardo Wurmus
2022-06-12  9:08   ` [PATCH 1/3] gwl/ui: Check for log-events configuration Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.guixwl.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220606194900.27725-1-olivier.dion@polymtl.ca \
    --to=olivier.dion@polymtl.ca \
    --cc=gwl-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).