From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: guile-devel@gnu.org
Cc: David Pirotte <david@altosw.be>
Subject: Re: [Guile-Lib PATCH v2 4/6] logging: Allow passing source properties to `log-msg'.
Date: Tue, 06 Feb 2024 09:15:59 -0500 [thread overview]
Message-ID: <87o7ct4r1c.fsf@gmail.com> (raw)
In-Reply-To: <20240206034201.28494-5-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Mon, 5 Feb 2024 22:41:13 -0500")
Hi,
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
> Note: this changes the API of the `accept-log' method by adding a new
> positional argument to it. `accept-log' is a "weak" public
> interface (mostly intended for internal uses or logging handler
> implementors), so this is deemed acceptable.
>
> * src/logging/logger.scm (log-helper) [source-properties]: New
> positional argument, which is passed to `accept-log'.
> * src/logging/logger.scm (log-msg): Update doc. Add two new variants
> that accept source properties. Annotate more LVL arguments with their
> type to ensure proper resolution.
> (default-log-formatter) [source-properties]: New optional argument,
> that is formatted as a source location prefix when available.
> (accept-log): Update doc. Add new source-properties argument, and
> pass it to the log-formatter procedure.
> * unit-tests/logging.logger.scm
> (test-log-with-source-properties): New test.
> * unit-tests/guile-library.api: Regenerate.
>
> ---
>
> Changes in v2:
> - Relax log-msg typing on source-properties, as it can also be #f
[...]
Some extra thoughts on the v2 change described above: perhaps instead
of dropping the class type from source-properties, it'd be
best to add two more define-method procedures, like so:
> (define-method (log-msg (lvl <symbol>) . objs)
> (if default-logger
> - (log-helper default-logger lvl objs)))
> + (log-helper default-logger lvl objs #f)))
> +
> +(define-method (log-msg source-properties (lvl <symbol>) . objs)
> + (if default-logger
> + (log-helper default-logger lvl objs source-properties)))
--8<---------------cut here---------------start------------->8---
(define-method (log-msg (source-properties <pair>) (lvl <symbol>) . objs)
(if default-logger
(log-helper default-logger lvl objs source-properties)))
(define-method (log-msg (source-properties <bool>) (lvl <symbol>) . objs)
(if default-logger
(log-helper default-logger lvl objs source-properties)))
--8<---------------cut here---------------end--------------->8---
As when using a syntactic wrapper for log-msg, source-properties would
typically be an alist, but may also be #f when running the code before
it was byte compiled.
> +
> +(define-method (log-msg (lgr <logger>) (lvl <symbol>) . objs)
> + (log-helper lgr lvl objs #f))
>
> -(define-method (log-msg (lgr <logger>) lvl . objs)
> - (log-helper lgr lvl objs))
> +(define-method (log-msg (lgr <logger>) source-properties
> + (lvl <symbol>) . objs)
> + (log-helper lgr lvl objs source-properties))
Likewise here, we'd need:
--8<---------------cut here---------------start------------->8---
(define-method (log-msg (lgr <logger>) (source-properties <pair>)
(lvl <symbol>) . objs)
(log-helper lgr lvl objs source-properties))
(define-method (log-msg (lgr <logger>) (source-properties <pair>)
(lvl <symbol>) . objs)
(log-helper lgr lvl objs source-properties))
--8<---------------cut here---------------end--------------->8---
Is that too many methods though? It seems the resolution mechanism is
probably fast enough to not matter.
Any thoughts?
--
Thanks,
Maxim
next prev parent reply other threads:[~2024-02-06 14:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240205194049.7757-1-maxim.cournoyer@gmail.com>
2024-02-06 3:41 ` [Guile-Lib PATCH v2 0/6] Make log-msg accept source properties for displaying source location Maxim Cournoyer
2024-02-06 3:41 ` [Guile-Lib PATCH v2 1/6] configure.ac: Fix typo in message Maxim Cournoyer
2024-02-06 3:41 ` [Guile-Lib PATCH v2 2/6] Use /bin/sh in update-api script shebang Maxim Cournoyer
2024-02-06 3:41 ` [Guile-Lib PATCH v2 3/6] tests: guile-library.api: Re-generate Maxim Cournoyer
2024-02-06 3:41 ` [Guile-Lib PATCH v2 4/6] logging: Allow passing source properties to `log-msg' Maxim Cournoyer
2024-02-06 14:15 ` Maxim Cournoyer [this message]
2024-02-06 3:41 ` [Guile-Lib PATCH v2 5/6] logging: Adjust default log-formatter output Maxim Cournoyer
2024-02-06 3:41 ` [Guile-Lib PATCH v2 6/6] logger: Call flush-log at the end of accept-log Maxim Cournoyer
2024-02-09 4:50 ` [Guile-Lib PATCH v3 0/7] Make log-msg accept source properties for displaying source location Maxim Cournoyer
2024-02-09 4:50 ` [Guile-Lib PATCH v3 1/7] configure.ac: Fix typo in message Maxim Cournoyer
2024-02-09 4:50 ` [Guile-Lib PATCH v3 2/7] Use /bin/sh in update-api script shebang Maxim Cournoyer
2024-02-09 4:50 ` [Guile-Lib PATCH v3 3/7] tests: guile-library.api: Re-generate Maxim Cournoyer
2024-02-09 4:50 ` [Guile-Lib PATCH v3 4/7] logging: Allow passing source properties to `log-msg' Maxim Cournoyer
2024-02-09 4:50 ` [Guile-Lib PATCH v3 5/7] logging: Adjust default log-formatter output Maxim Cournoyer
2024-02-09 4:50 ` [Guile-Lib PATCH v3 6/7] logging: Make procedure name available to the log formatter Maxim Cournoyer
2024-02-09 4:50 ` [Guile-Lib PATCH v3 7/7] logging: Call flush-log at the end of accept-log Maxim Cournoyer
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.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o7ct4r1c.fsf@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=david@altosw.be \
--cc=guile-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).