[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-Lib PATCH 6/6] logger: Call flush-log at the end of accept-log.
From: |
Maxim Cournoyer |
Subject: |
[Guile-Lib PATCH 6/6] logger: Call flush-log at the end of accept-log. |
Date: |
Mon, 5 Feb 2024 14:40:36 -0500 |
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.
---
src/logging/logger.scm | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/logging/logger.scm b/src/logging/logger.scm
index 5403531..d9c3722 100644
--- a/src/logging/logger.scm
+++ b/src/logging/logger.scm
@@ -341,12 +341,13 @@ 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}
-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
-given at @var{handler}'s creation time, or by the default if none was
-given.
+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} 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 given at
+@var{handler}'s creation time, or by the default if none was given.
This method should not normally need to be overridden by subclasses.
This method should not normally be called by users of the logging
@@ -358,7 +359,8 @@ override this behavior.")
(define-method (accept-log (self <log-handler>) level time str
source-properties)
(when (level-enabled? self level)
- (emit-log self ((log-formatter self) level time str source-properties))))
+ (emit-log self ((log-formatter self) level time str source-properties))
+ (flush-log self)))
;; This should be overridden by all log handlers to actually
;; write out a string.
--
2.41.0
- [Guile-Lib PATCH 0/6] Make log-msg accept source properties for displaying source location, Maxim Cournoyer, 2024/02/05
- [Guile-Lib PATCH 1/6] configure.ac: Fix typo in message., Maxim Cournoyer, 2024/02/05
- [Guile-Lib PATCH 2/6] Use /bin/sh in update-api script shebang., Maxim Cournoyer, 2024/02/05
- [Guile-Lib PATCH 3/6] tests: guile-library.api: Re-generate., Maxim Cournoyer, 2024/02/05
- [Guile-Lib PATCH 4/6] logging: Allow passing source properties to `log-msg'., Maxim Cournoyer, 2024/02/05
- [Guile-Lib PATCH 5/6] logging: Adjust default log-formatter output., Maxim Cournoyer, 2024/02/05
- [Guile-Lib PATCH 6/6] logger: Call flush-log at the end of accept-log.,
Maxim Cournoyer <=