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: Re: [Guile-Lib PATCH v2 4/6] logging: Allow passing source properties to `log-msg'. Date: Tue, 06 Feb 2024 09:15:59 -0500 Message-ID: <87o7ct4r1c.fsf@gmail.com> References: <20240205194049.7757-1-maxim.cournoyer@gmail.com> <20240206034201.28494-1-maxim.cournoyer@gmail.com> <20240206034201.28494-5-maxim.cournoyer@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34827"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: David Pirotte To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Tue Feb 06 15:16:39 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 1rXMFa-0008si-RD for guile-devel@m.gmane-mx.org; Tue, 06 Feb 2024 15:16:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXMFD-0001Xs-G1; Tue, 06 Feb 2024 09:16:15 -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 1rXMF8-0001Tb-BO for guile-devel@gnu.org; Tue, 06 Feb 2024 09:16:12 -0500 Original-Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXMF2-0001SR-4L for guile-devel@gnu.org; Tue, 06 Feb 2024 09:16:08 -0500 Original-Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3be6ff4f660so3584908b6e.3 for ; Tue, 06 Feb 2024 06:16:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707228961; x=1707833761; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=xdnX3bj3TsdL/1Gm89fxgIJUiAw0j7w8txCrIDCm2sY=; b=crd/x/Dxn9AZ9U87Gwwqkx/L9hYVYYu34XCIoUTkDDQM8UmTI399vmr0siTBzqvjdu KleoNC1nvXen1H2AHsPDVGvgoWHSBgEM4MGL8ABJ84guiFmdK49wApMF0818hTNibbuc PIHcodlBNLLq9CLEj1oBm4PErRL2XZtEmcqq43LuwTTeNX1B01Duz4YEx75cKl2s5xWZ 8gjxQVGKNnozWRWZCqIno4auIhbLuFzxHtDol/Rs2AdxEx5MqXSDUlNpcd6/mhFRM/fe AHL3f58CRJ+j4q+iCDUa5as7wGt92vRvOTQhBZg/3iS6pcOuWCaFhZ3rgQfYNVbLaas4 t3yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707228961; x=1707833761; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xdnX3bj3TsdL/1Gm89fxgIJUiAw0j7w8txCrIDCm2sY=; b=n2G1jYrekr2jJur9su/fuYcacurjo3H535JmksExKY7ocm5LLWUML+Ym+DeAOgGZUI x9V/OyITxQvJGgF/9oZXpkHomrKBw3+EnAV2lmOhCc1rJkgVUX8MthrLBft+c5JaqaXG GAomimNusJRsn4mYlZmmt5sPkDK9lQ6uZj/kbNjyPcIc72nwm5BxNNuo8p38e9XKSewD zjOLXbJGS6KcQB4naPF6gIlwSdsvGIQExg4//qcuJdOyPc+Lkj4FXCjVujOVXNAoAY+Y /k2wKJvsOUdLGwKmPhiYZ5YRrmq57f33diDwHNFkRtydehSez0LhjlmlEbbL+0gwtwmS HbQQ== X-Gm-Message-State: AOJu0Yx9FzXw6FFjweXNO+3FR1902QuCKFCdTpMlPLB30QBDz1UwmQ52 vEV3yxIIAJGEqmNn3iwfsIiRG94MQTyYoBGUKJmQjCQ0jPvzRNcsiuxTXtTE X-Google-Smtp-Source: AGHT+IEsQOwYPCZSIbSE8R7NDU7G0tu8tzIQ4DRjOjCipStI/T4E/WMbtPzCtpMEUUyxj7xjm0tonA== X-Received: by 2002:a05:6808:1688:b0:3bc:3c91:e2f1 with SMTP id bb8-20020a056808168800b003bc3c91e2f1mr3294555oib.55.1707228961433; Tue, 06 Feb 2024 06:16:01 -0800 (PST) Original-Received: from hurd (dsl-10-130-152.b2b2c.ca. [72.10.130.152]) by smtp.gmail.com with ESMTPSA id e19-20020a05620a209300b00783268da8f0sm930302qka.40.2024.02.06.06.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 06:16:00 -0800 (PST) In-Reply-To: <20240206034201.28494-5-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Mon, 5 Feb 2024 22:41:13 -0500") Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=maxim.cournoyer@gmail.com; helo=mail-oi1-x236.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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:22303 Archived-At: Hi, Maxim Cournoyer writes: > Note: this changes the API of the `accept-log' method by adding a new > positional argument to it. `accept-log' is a "weak" public > interface (mostly intended for internal uses or logging handler > implementors), so this is deemed acceptable. > > * src/logging/logger.scm (log-helper) [source-properties]: New > positional argument, which is passed to `accept-log'. > * src/logging/logger.scm (log-msg): Update doc. Add two new variants > that accept source properties. Annotate more LVL arguments with their > type to ensure proper resolution. > (default-log-formatter) [source-properties]: New optional argument, > that is formatted as a source location prefix when available. > (accept-log): Update doc. Add new source-properties argument, and > pass it to the log-formatter procedure. > * unit-tests/logging.logger.scm > (test-log-with-source-properties): New test. > * unit-tests/guile-library.api: Regenerate. > > --- > > Changes in v2: > - Relax log-msg typing on source-properties, as it can also be #f [...] Some extra thoughts on the v2 change described above: perhaps instead of dropping the class type from source-properties, it'd be best to add two more define-method procedures, like so: > (define-method (log-msg (lvl ) . objs) > (if default-logger > - (log-helper default-logger lvl objs))) > + (log-helper default-logger lvl objs #f))) > + > +(define-method (log-msg source-properties (lvl ) . objs) > + (if default-logger > + (log-helper default-logger lvl objs source-properties))) --8<---------------cut here---------------start------------->8--- (define-method (log-msg (source-properties ) (lvl ) . objs) (if default-logger (log-helper default-logger lvl objs source-properties))) (define-method (log-msg (source-properties ) (lvl ) . objs) (if default-logger (log-helper default-logger lvl objs source-properties))) --8<---------------cut here---------------end--------------->8--- As when using a syntactic wrapper for log-msg, source-properties would typically be an alist, but may also be #f when running the code before it was byte compiled. > + > +(define-method (log-msg (lgr ) (lvl ) . objs) > + (log-helper lgr lvl objs #f)) > > -(define-method (log-msg (lgr ) lvl . objs) > - (log-helper lgr lvl objs)) > +(define-method (log-msg (lgr ) source-properties > + (lvl ) . objs) > + (log-helper lgr lvl objs source-properties)) Likewise here, we'd need: --8<---------------cut here---------------start------------->8--- (define-method (log-msg (lgr ) (source-properties ) (lvl ) . objs) (log-helper lgr lvl objs source-properties)) (define-method (log-msg (lgr ) (source-properties ) (lvl ) . objs) (log-helper lgr lvl objs source-properties)) --8<---------------cut here---------------end--------------->8--- Is that too many methods though? It seems the resolution mechanism is probably fast enough to not matter. Any thoughts? -- Thanks, Maxim