[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Logging in Guile
From: |
Roel Janssen |
Subject: |
Re: Logging in Guile |
Date: |
Mon, 13 Jan 2020 22:42:08 +0100 |
User-agent: |
Evolution 3.34.3 (3.34.3-1.fc31) |
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