From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Roel Janssen Newsgroups: gmane.lisp.guile.user Subject: Re: Logging in Guile Date: Mon, 13 Jan 2020 22:42:08 +0100 Message-ID: References: <3d636a08-f49d-c06f-2436-1838d3a652f2@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="45736"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Evolution 3.34.3 (3.34.3-1.fc31) To: Zelphir Kaltstahl , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon Jan 13 22:45:06 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ir7Td-0010js-Le for guile-user@m.gmane-mx.org; Mon, 13 Jan 2020 22:42:25 +0100 Original-Received: from localhost ([::1]:56122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ir7Tc-0002eI-G0 for guile-user@m.gmane-mx.org; Mon, 13 Jan 2020 16:42:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35321) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ir7TQ-0002dc-Hv for guile-user@gnu.org; Mon, 13 Jan 2020 16:42:13 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:32865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ir7TQ-0005m6-DT; Mon, 13 Jan 2020 16:42:12 -0500 Original-Received: from 2001-1c02-0b03-a700-f532-4553-7f2a-9b68.cable.dynamic.v6.ziggo.nl ([2001:1c02:b03:a700:f532:4553:7f2a:9b68]:58496) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ir7TP-0004IA-Q6; Mon, 13 Jan 2020 16:42:12 -0500 In-Reply-To: <3d636a08-f49d-c06f-2436-1838d3a652f2@posteo.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:16051 Archived-At: On Mon, 2020-01-13 at 19:06 +0100, Zelphir Kaltstahl wrote: > Hi Guile Users! > > Is there any library for logging in Guile? > > What I imagine is something, where I can log messages of various levels, > like debug, info, error and such. Currently I am using display and > simple-format for all the things, but it would be nice to be able to run > a program and give it some log level, so that only the log messages of > that level or above in importance are shown. Then I could leave all my > logging in my code and set it to debug level or, if intended to be seen > for the user, set it to info level, or if there really is an error, I > could set it to error level. > > On a quick search I could not find anything. > > Regards, > Zelphir I'm using a rather simple module that distinguishes errors from warnings and debug: https://github.com/UMCUGenetics/sparqling-genomics/blob/master/web/logger.scm You could implement your own log levels easily.. So you can use it like this: (log-error "the-calling-function" "A ~a ~a ~a" "format" "like" "format") (log-debug "the-calling-function" "Similar to ~a" 'log-error) (log-warning "the-calling-function" "Similar to ~a" 'log-debug) Then there are three functions that return a port to write to: (default-error-port) (default-warning-port) (default-debug-port) When (null? port) => #t, no message is written. See: https://github.com/UMCUGenetics/sparqling-genomics/blob/dc5fea515c30aa26ff60b77911438689473d125b/web/ldap/authenticate.scm.in#L148 Kind regards, Roel Janssen