diff mbox series

[bug#55242,03/10] guix: import: go: Add mockup logging facility.

Message ID 20220503114301.9524-3-attila@lendvai.name
State New
Headers show
Series None | expand

Commit Message

Attila Lendvai May 3, 2022, 11:42 a.m. UTC
Introduce a (local) mockup logger, so that we don't need to keep adding and
deleting format's when debugging the codebase.

* guix/import/go.scm (log.info) (log.debug): New macros.
---
 guix/import/go.scm | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

M May 3, 2022, 4:23 p.m. UTC | #1
Attila Lendvai schreef op di 03-05-2022 om 13:42 [+0200]:
> +;; FIXME set up logging for the entire project, and replace this poor man's
> +;; logger with the proper one.
> +(define-syntax-rule (log.info format-string ...)
> +  (let ((port (current-warning-port)))
> +    (format port format-string ...)
> +    (newline port)))
> +
> +(define-syntax-rule (log.debug format-string ...)
> +  ;;(log.info format-string ...)
> +  '())

We already have a logging functionality: 'info' from
guix/diagnostics.scm.  No 'debug' yet though ...

Greetings,
Maxime.
Maxim Cournoyer June 14, 2022, 7:46 p.m. UTC | #2
Hello Attila,

Attila Lendvai <attila@lendvai.name> writes:

> Introduce a (local) mockup logger, so that we don't need to keep adding and
> deleting format's when debugging the codebase.
>
> * guix/import/go.scm (log.info) (log.debug): New macros.
> ---
>  guix/import/go.scm | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/guix/import/go.scm b/guix/import/go.scm
> index bb4bb7bb7b..0af5e4b5e2 100644
> --- a/guix/import/go.scm
> +++ b/guix/import/go.scm
> @@ -100,6 +100,17 @@ (define-module (guix import go)
>  
>  ;;; Code:
>  
> +;; FIXME set up logging for the entire project, and replace this poor man's
> +;; logger with the proper one.
> +(define-syntax-rule (log.info format-string ...)
> +  (let ((port (current-warning-port)))
> +    (format port format-string ...)
> +    (newline port)))
> +
> +(define-syntax-rule (log.debug format-string ...)
> +  ;;(log.info format-string ...)
> +  '())
> +

We alreading have 'warning' and 'info' in (guix diagnostics); perhaps we
could also have 'debug', enabled when GUIX_DEBUG is set or something.
Alternatively, there's a full blown logging library available in the
Guile-Lib project, as (logging logger) [0].

[0]  https://www.nongnu.org/guile-lib/doc/ref/logging.logger/

Maxim
diff mbox series

Patch

diff --git a/guix/import/go.scm b/guix/import/go.scm
index bb4bb7bb7b..0af5e4b5e2 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -100,6 +100,17 @@  (define-module (guix import go)
 
 ;;; Code:
 
+;; FIXME set up logging for the entire project, and replace this poor man's
+;; logger with the proper one.
+(define-syntax-rule (log.info format-string ...)
+  (let ((port (current-warning-port)))
+    (format port format-string ...)
+    (newline port)))
+
+(define-syntax-rule (log.debug format-string ...)
+  ;;(log.info format-string ...)
+  '())
+
 (define http-fetch*
   ;; Like http-fetch, but memoized and returning the body as a string.
   (memoize (lambda args