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 v3 5/7] logging: Adjust default log-formatter output. Date: Thu, 8 Feb 2024 23:50:46 -0500 Message-ID: <20240209045150.17210-6-maxim.cournoyer@gmail.com> References: <20240206034201.28494-1-maxim.cournoyer@gmail.com> <20240209045150.17210-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="18555"; 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 Fri Feb 09 05:52:45 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 1rYIsW-0004d3-F3 for guile-devel@m.gmane-mx.org; Fri, 09 Feb 2024 05:52:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYIrv-0006vl-Se; Thu, 08 Feb 2024 23:52:07 -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 1rYIrt-0006sg-TJ for guile-devel@gnu.org; Thu, 08 Feb 2024 23:52:05 -0500 Original-Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYIrs-0000QL-F1 for guile-devel@gnu.org; Thu, 08 Feb 2024 23:52:05 -0500 Original-Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-78407987510so30722885a.3 for ; Thu, 08 Feb 2024 20:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707454323; x=1708059123; 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=1u7wZSoIAW4qzRNzGV8IBTZO1dBtJTqF4PwoEgqvWUs=; b=j6DmQbcIQUgTzDGHmxaPMzyKCHEii1v9oY6lAu0SbUw7A8QJUJf552IsUZZV7C4BDu E3HvibdijRJJZIZaenn5d+eT/jd3KCPMtGdPwxF3X4HGucZb9P9DBQskFS0UzWZAUhDH E+Q+zsCKV6sqLsOicyi1r0dH/y7+DBcuHbsS4vphTx9NzkM9Kg3SGaNCQvAvlNv8ldwq OBpq4zaQn6I9QpKENUKXa9k+wi8ISMa7ZUM5VnMuxlDr4A35X6Obl0XuxNdgfQlzRaI5 Wzm2Bjtvi2sC2+aFd6qURArCswy+UhdcgZrJmbx8q1e8Rp5CkSBwzxvvMS+Z76KH0i21 6eGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707454323; x=1708059123; 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=1u7wZSoIAW4qzRNzGV8IBTZO1dBtJTqF4PwoEgqvWUs=; b=N78HGBh7RSY6yunkiLW9Oh6AaTtCkyk0lFehb/9IgqZEQ2+yl7Vrv+AW6USmaqqsdp M0Jrrvg6T9H6wJ5iZuEKop06O+GPmcQJF0fmkMAJBmBKPRgd03U5ZWoZoUoYMQuILs9s My/FIN+xfNjLdPlfC8e1cSU1tHYJsD6fv3Pf2BNakwSR2YgsoUNk9Ko4h5SFOJX1qnlC GkCgJ4SI13pg0Jw+UnDFe8oFIna2ChrZIz3QjGCyKEWa3V7fdeDrnkqGYlfX9fpIaTfk Im5JOWRzCC9eGXFxGyLrRxVG3G2z7lW5DcQGegUMRgu5VR1RR+/aBJhu5uiV5QjvbKFj MPdw== X-Gm-Message-State: AOJu0YwypW4duXb965khYnC36PuJuQbUPktaI1F4hms1zaxeKP2wg2e9 PvlX/t57BVjbT9UZRPPPFHJr482jwAZa5q6Sof6aQkBiaOoXvGYQTr6Q69mq X-Google-Smtp-Source: AGHT+IFp60oFLuWrzx7pFmHWKTAG/I5SGUXiW9gCHJsLLKbvfw+VWmusyQbY8Nf3OL2HQq9HBk9dqQ== X-Received: by 2002:a05:620a:40c3:b0:783:dcc4:cd40 with SMTP id g3-20020a05620a40c300b00783dcc4cd40mr730178qko.10.1707454322888; Thu, 08 Feb 2024 20:52:02 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWKW/W03AyyXFbL2zmlQ4sJppLg7elG0b9GkJUhSyKvBH/h79NhTrJtEm7GM2XgmQ4rs9h8tWXc3hgD2omUcwaqqXu4sH221OMD Original-Received: from localhost.localdomain (dsl-10-135-252.b2b2c.ca. [72.10.135.252]) by smtp.gmail.com with ESMTPSA id p3-20020a05620a112300b00785a2d275f0sm426970qkk.41.2024.02.08.20.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 20:52:02 -0800 (PST) X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240209045150.17210-1-maxim.cournoyer@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qk1-x72d.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:22312 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 7b32ffe..05850a9 100644 --- a/src/logging/logger.scm +++ b/src/logging/logger.scm @@ -294,7 +294,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