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


Reply via email to