unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: guile-devel@gnu.org
Cc: David Pirotte <david@altosw.be>,
	Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [Guile-Lib PATCH v4 7/7] logging: Call flush-log at the end of accept-log.
Date: Sun, 25 Feb 2024 09:19:13 -0500	[thread overview]
Message-ID: <20240225141935.8420-8-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20240225141935.8420-1-maxim.cournoyer@gmail.com>

  This is to avoid long block buffering of log messages, which would
  causes the log messages to be delayed, which is likely to confuse
  users attempting to follow the logs in real time (see:
  https://lists.gnu.org/archive/html/guile-devel/2024-01/msg00000.html).

* src/logging/logger.scm (accept-log): Call flush-log after a log is
  emitted.  Update doc.

---

(no changes since v1)

 src/logging/logger.scm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/logging/logger.scm b/src/logging/logger.scm
index b75d603..eee33a5 100644
--- a/src/logging/logger.scm
+++ b/src/logging/logger.scm
@@ -344,7 +344,9 @@ registered handlers.")
 (define-generic-with-docs accept-log
 "@code{accept-log handler lvl time str}.  If @var{lvl} is
 enabled for @var{handler}, then @var{str} will be formatted and sent
-to the log via the @code{emit-log} method.  @var{source-properties} is
+to the log via the @code{emit-log} method.  @code{flush-port} is
+called after emitting a log to ensure users tailing the source file
+can see new messages in real time.  @var{source-properties} is
 optional; it can be either @code{#f} or an association list containing
 the file name, line, and column source information provided to the
 @code{log-msg} call.  Formatting is done via the formatting function
@@ -368,7 +370,8 @@ override this behavior.")
   (when (level-enabled? self level)
     (emit-log self ((log-formatter self) level time str
                     #:source-properties source-properties
-                    #:proc-name proc-name))))
+                    #:proc-name proc-name))
+    (flush-log self)))
 
 ;; This should be overridden by all log handlers to actually
 ;; write out a string.
-- 
2.41.0




      parent reply	other threads:[~2024-02-25 14:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-25 14:19 [Guile-Lib PATCH v4 0/7] Make log-msg accept source properties for displaying source location Maxim Cournoyer
2024-02-25 14:19 ` [Guile-Lib PATCH v4 1/7] configure.ac: Fix typo in message Maxim Cournoyer
2024-02-25 14:19 ` [Guile-Lib PATCH v4 2/7] Use /bin/sh in update-api script shebang Maxim Cournoyer
2024-02-25 14:19 ` [Guile-Lib PATCH v4 3/7] tests: guile-library.api: Re-generate Maxim Cournoyer
2024-02-25 14:19 ` [Guile-Lib PATCH v4 4/7] logging: Allow passing source properties to `log-msg' Maxim Cournoyer
2024-02-25 14:19 ` [Guile-Lib PATCH v4 5/7] logging: Adjust default log-formatter output Maxim Cournoyer
2024-02-25 14:19 ` [Guile-Lib PATCH v4 6/7] logging: Make procedure name available to the log formatter Maxim Cournoyer
2024-02-25 14:19 ` Maxim Cournoyer [this message]

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=20240225141935.8420-8-maxim.cournoyer@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).