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 v4 5/7] logging: Adjust default log-formatter output. Date: Sun, 25 Feb 2024 09:19:11 -0500 Message-ID: <20240225141935.8420-6-maxim.cournoyer@gmail.com> References: <20240225141935.8420-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="13673"; 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 Sun Feb 25 15:20:04 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 1reFMK-0003QY-1A for guile-devel@m.gmane-mx.org; Sun, 25 Feb 2024 15:20:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1reFM7-0002Mq-RN; Sun, 25 Feb 2024 09:19:51 -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 1reFM6-0002Mf-Tj for guile-devel@gnu.org; Sun, 25 Feb 2024 09:19:50 -0500 Original-Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reFM5-0004Vb-Fd for guile-devel@gnu.org; Sun, 25 Feb 2024 09:19:50 -0500 Original-Received: by mail-qv1-xf2d.google.com with SMTP id 6a1803df08f44-68fb730fdd5so9417586d6.2 for ; Sun, 25 Feb 2024 06:19:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708870788; x=1709475588; 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=yFlqGMIiGepMk3XdKqsH8AnsaUbG1276hzHHSJSmRAQ=; b=Pv+YMI0KrB1AQ8xathKPKWuLrTjNJ76kKm6j5FSr2eJJIm2tfwdiqOATO2tZZMJb/s Tplt1GVWmbh6lmYWoGrRI49vWWrlTvZyiSyxFHsEbkxR6/xJjR5OwT09Q+npg+ccsGuH UptxFC51H9b2Mf5BorqciqiXffBjtdWr3V/rdkoKR1ryju8+fBM8PHxD192IfytbUcY4 fZFkflRxwN6fGLMh4JYJmDN1aWT9oV/QmazjLJJcR8hy/xqqVW22joVkkr+B57fsLebz gjhjw1701p9qvQP+AP+CbUyVhSnzu29LwsBzd7bF0kcwpdeWI4Pb2gNAF5tuP8Qv1/eV SEzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708870788; x=1709475588; 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=yFlqGMIiGepMk3XdKqsH8AnsaUbG1276hzHHSJSmRAQ=; b=AgyondNEi7nIJFOi+NdJkibhld26c+ZAAS8PXn0y1yDmivw74KUHHbUYnP0X8BbF3l bVS8FnyVlhobO5zxYYf9UEHLavI8y4nWfks6I9K6bVs0ls5fSGb93qI4sxzrpDb9HQva YqLcsPFjsZA4KrS7E8W3yb6OBD7qo3VhcLMycsYnNJbu8++kTbQLAIIxA0LMc9UkNMBM 7EIp0B95Uk/Dz3lcvbzA5vNARKRkMsUWE2ucfUWqu3+uulnpQtbfuymGxDrN4fLhxD1n C28bT4IeiDQlXLEuYsJqJUe4HU0wwvuM2s5iMUPvL98HmyCCpEoeuWMO0H6YhzD/JJu5 X70w== X-Gm-Message-State: AOJu0Ywj1Fggfeows3uuKsk7EIDbj43Kg3mFlZJ1xsJszXfAVRtd1yBL KFQ0jNh+fBz2GVcej2ZvkKl1pC3zbumufhV2D7BldmJ8FBKcup6rBkbY3SqV X-Google-Smtp-Source: AGHT+IFtPtGahn59QFf12IJBQ9HtMYNvd7A1UgDfEdl+jjPizpD2bLhomZffHLhxvwX/joeEonSwGQ== X-Received: by 2002:a0c:da07:0:b0:68f:2d21:d634 with SMTP id x7-20020a0cda07000000b0068f2d21d634mr6480918qvj.24.1708870788012; Sun, 25 Feb 2024 06:19:48 -0800 (PST) Original-Received: from localhost.localdomain (dsl-141-6.b2b2c.ca. [66.158.141.6]) by smtp.gmail.com with ESMTPSA id kr2-20020a0562142b8200b0068fcaa599f6sm1780591qvb.67.2024.02.25.06.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 06:19:47 -0800 (PST) X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240225141935.8420-1-maxim.cournoyer@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::f2d; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qv1-xf2d.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:22322 Archived-At: The log level is always in uppercase, and its surrounding parentheses are dropped. * src/logging/logger.scm (default-log-formatter): Uppercase level and strip its surrounding parens. * unit-tests/logging.logger.scm: Adjust expected output accordingly. --- (no changes since v1) src/logging/logger.scm | 2 +- unit-tests/logging.logger.scm | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/logging/logger.scm b/src/logging/logger.scm index e53661d..6a5b824 100644 --- a/src/logging/logger.scm +++ b/src/logging/logger.scm @@ -296,7 +296,7 @@ suitable syntax wrapper (currently left to the user to implement)." ;; '(standards) Errors'). (line (and=> (assoc-ref source-properties 'line) 1+)) (column (assoc-ref source-properties 'column))) - (format #f "~a ~@[~a ~](~a): ~a~%" + (format #f "~a ~@[~a ~]~:@(~a~): ~a~%" (strftime "%F %H:%M:%S" (localtime time)) (and (or file-name line column) (format #f "~@[~a:~]~@[~a:~]~@[~a:~]" file-name line column)) diff --git a/unit-tests/logging.logger.scm b/unit-tests/logging.logger.scm index d26587c..2093bf2 100644 --- a/unit-tests/logging.logger.scm +++ b/unit-tests/logging.logger.scm @@ -30,7 +30,7 @@ (lgr (make #:handlers (list (make #:port strport))))) (open-log! lgr) (log-msg lgr 'CRITICAL "Hello!") - (assert-equal "(CRITICAL): Hello!\n" + (assert-equal "CRITICAL: Hello!\n" ;; skip over the time/date, since that will vary! (substring (get-output-string strport) 20)))) @@ -41,7 +41,7 @@ (set-default-logger! lgr) (log-msg 'CRITICAL "Hello!") (set-default-logger! #f) - (assert-equal "(CRITICAL): Hello!\n" + (assert-equal "CRITICAL: Hello!\n" ;; skip over the time/date, since that will vary! (substring (get-output-string strport) 20)))) @@ -50,7 +50,7 @@ (lgr (make #:handlers (list (make #:port strport))))) (register-logger! "main" lgr) (log-msg (lookup-logger "main") 'CRITICAL "Hello!") - (assert-equal "(CRITICAL): Hello!\n" + (assert-equal "CRITICAL: Hello!\n" ;; skip over the time/date, since that will vary! (substring (get-output-string strport) 20)))) -- 2.41.0