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 6/6] logger: Call flush-log at the end of accept-log. Date: Mon, 5 Feb 2024 14:40:36 -0500 Message-ID: <20240205194049.7757-7-maxim.cournoyer@gmail.com> References: <20240205194049.7757-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="22377"; 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 Mon Feb 05 20:42:24 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 1rX4rI-0005Zg-61 for guile-devel@m.gmane-mx.org; Mon, 05 Feb 2024 20:42:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rX4rA-0006gC-LP; Mon, 05 Feb 2024 14: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 1rX4r9-0006g3-Q8 for guile-devel@gnu.org; Mon, 05 Feb 2024 14:42:15 -0500 Original-Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rX4r8-0004tX-1r for guile-devel@gnu.org; Mon, 05 Feb 2024 14:42:15 -0500 Original-Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3bfdc1c0a2aso681999b6e.1 for ; Mon, 05 Feb 2024 11:42:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707162132; x=1707766932; 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=B+LslR60kYpIGaxCp2793831slwAXhi0MCDABZjvF18=; b=UFaSkedzI2Qq3i3gMh0vhBE5mBj6aelvzo8B1ttOgwsTZIYGdBBGtbtt8z/LgtXvNI DbWlE7PPtbBp2yRYFi99uxGaLPqPdJQx4DPfy0Vtp70rOb58RrCweftVC+WpCODshbS2 Hak2feRbKlqHVMP4pFBvfM9p+zlpzeTkudUT/wtKir4655DAirv/aG4o2sRoUI6Wbv4q kL9bHIZ3Yo58zEEtAfh5F8GyxHjV1EfhMB2KN68crp/I2Of6QvGvY8LGZAu/NvrOcAaD Zz1tAFLLNok3DNn8ZfCYjzmBenYQu38Fzw9w6YZ7ThMvjfnRnS14wGGjABGt4eXCZdQB 5ffA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707162132; x=1707766932; 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=B+LslR60kYpIGaxCp2793831slwAXhi0MCDABZjvF18=; b=FT0IU1rVT6eD3ObkuJJFxTQLUB6u6UzYd/92JhNquWaWli3XTqvOt5lSNyJn+i3130 F1CNCozyTBMATLd9vCeRmMkghpcjg4dQ+huXvo1kTP5xcrzVssTwmBPuF/mMnyDMpnx5 X6PB+CLHb/4r2pBif4qbCVsXj73qKzxmzxrGwAC97kWYeDQaJOnuiLX5f0sTR5aVWq4N F2QPgJaWW9J71bOg4ssF+v97d4P2G5rdS3vsCKwQkFwZXS6M6inmjleaC016R+JNF2DR 2pZ5GvlxX5jA2kbh8a0Vi3vUhPA/Udbn2zabp7L3FhQDkr4wuo4b8Vwmr0wdHoxXz9qr j46w== X-Gm-Message-State: AOJu0Ywho1MyTXBmjyyEVes8yRN5v22WiKWdXRJghYzG8erObmEcYGlH DwSJZKAu9WVY2e+NKwVIlJBkqnVUJsSyMWS0WhMOutePYD6R+98yloz3wOWf X-Google-Smtp-Source: AGHT+IHyBHDj3E1KF9rg3Soa4kPo5J2KLthSx6KmZTDp90hnbFJ+5JtSnwroNKn+X9ph79En9/jnDg== X-Received: by 2002:a05:6808:1590:b0:3bf:cecd:b741 with SMTP id t16-20020a056808159000b003bfcecdb741mr863749oiw.38.1707162131909; Mon, 05 Feb 2024 11:42:11 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX00/IhQx18b8+AbEqYjT+dpRGqPod+gvncPxv+3g25teOua4lRklreDEMKZfRh4s0X8aQMYmKOyinamsefsvvf29zLEwS23eRc Original-Received: from localhost.localdomain (dsl-10-130-152.b2b2c.ca. [72.10.130.152]) by smtp.gmail.com with ESMTPSA id a12-20020a05620a102c00b00783da2644besm217367qkk.136.2024.02.05.11.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 11:42:11 -0800 (PST) X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240205194049.7757-1-maxim.cournoyer@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::229; envelope-from=maxim.cournoyer@gmail.com; helo=mail-oi1-x229.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:22294 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. --- 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 ) 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