From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxim Cournoyer Newsgroups: gmane.lisp.guile.devel Subject: [Guile-Lib PATCH v2 6/6] logger: Call flush-log at the end of accept-log. Date: Mon, 5 Feb 2024 22:41:15 -0500 Message-ID: <20240206034201.28494-7-maxim.cournoyer@gmail.com> References: <20240205194049.7757-1-maxim.cournoyer@gmail.com> <20240206034201.28494-1-maxim.cournoyer@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9595"; mail-complaints-to="usenet@ciao.gmane.io" Cc: David Pirotte , Maxim Cournoyer To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Tue Feb 06 04:42:27 2024 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rXCLq-0002Ao-BU for guile-devel@m.gmane-mx.org; Tue, 06 Feb 2024 04:42:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXCLg-0006MN-S8; Mon, 05 Feb 2024 22:42:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXCLf-0006M1-Gh for guile-devel@gnu.org; Mon, 05 Feb 2024 22:42:15 -0500 Original-Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXCLd-0002eS-VR for guile-devel@gnu.org; Mon, 05 Feb 2024 22:42:15 -0500 Original-Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-42a9c21f9ecso30357781cf.0 for ; Mon, 05 Feb 2024 19:42:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707190933; x=1707795733; darn=gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9VNXGuwPY7Ya0s0H7x6AlYUsODMhbIG1L64ryOIPL4A=; b=R7bRC8Wp+JB58Fqz2gNxThQkC60ozsRDWV0o6GnooTxdydbYJTrLlVRQtAJlzWcb1H QZgC3Wdhwm8/JFUJJZ4ycJt75ot/Bg5OJ6qx4G1WrdTjLuAfPFSp2IkCOt1/txIzSHOp 3BOI6TUreZGMN8XlH6gH5v8AUKxWxOOGVjkCoc8Yfl7ZNI66yilbQX1Fxv1tNsNzLhCS yzzlzrCcd/aGGvECjEDFwG8TBWsRz/XNCRscxjTA6u4WpR8hfaGEzChsXh3rO1/yPhXB 2hocbD88Ni7eHmAM59WTkl5xTi7zj2QVgykVYLJcU9w8+T2x0WoemZvovbsBhIft+xYs mkow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707190933; x=1707795733; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9VNXGuwPY7Ya0s0H7x6AlYUsODMhbIG1L64ryOIPL4A=; b=LJfVb3egdWFraDWJhjQYLhg/Ne8jqL9qQEvuJqPXZHUvjt1nup2ncIBhaz8fmD+OEy 6pDiVtwVmGUZXSQcffINzLQcJKfbh04w+0Grga+G+uxJYP8Tgxov8xPKuQ3AWBn2nbb8 u4UZ38RTPrQvvowNo2FK/JAwcHPFB9UP+nmmSycZo+jPqqnKtf8nGVFzXkieWGf/TxAL qfE3HMxm5hQ74i3jhJeB1p88uu9fnUIFA+AUZ66muJhBCOCOor/nkkr2ANLgg9YNO0au oEPnfIAC8zd6EGH18LrefFpoDwFlHlHHd3dMLmYhc8KFgT4UrPEK+ZNOJS0kIW4RqIJJ iZzw== X-Gm-Message-State: AOJu0YzLAvuSbyxp7YWCzpcoCap5TMCMBR5LB2tGLERfIcBC13tikigZ R+iQHVDQtRv6SlYMAYdq7jIb7LlmlB4U8Q4jzIX+6J6C6dNNqPS+8Iv1VAh/ X-Google-Smtp-Source: AGHT+IEMe/MqowZR8GrhQB72XItG6JbpMjlC8m+UDMmNRAYaMGqanbBwJB0/6IQRt46vR3J68QV0cQ== X-Received: by 2002:a05:6214:daa:b0:68c:4f54:5bd8 with SMTP id h10-20020a0562140daa00b0068c4f545bd8mr1265492qvh.32.1707190932722; Mon, 05 Feb 2024 19:42:12 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXisicI4spf0zAejtaIS1cLm6iUmEmA56h5p1VDu48kH+rxr37qCSfbmTYnySe5S9uuC6p79bTYEnQg+tFTd2Ds3UgH7JPksfh4 Original-Received: from localhost.localdomain (dsl-10-130-152.b2b2c.ca. [72.10.130.152]) by smtp.gmail.com with ESMTPSA id mv6-20020a056214338600b0068c963dd12asm626458qvb.86.2024.02.05.19.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 19:42:11 -0800 (PST) X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240206034201.28494-1-maxim.cournoyer@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::82c; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x82c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22297 Archived-At: 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 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/logging/logger.scm b/src/logging/logger.scm index e57cd44..d61acf1 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 ) 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