Thanks, Neil. Unfortunately #2 didn't work. The historically written
define-logger calls like log-something-debug overwrites the "foo" topic
with "something". If only they were appended together. #3 can't intercept
logs of define-logger loggers (if a woodchuck could...) even with
topic/level hardcoded because the #:logger keyword is also needed. So it
seems like the usage would be a series of nested with-intercepted-loggings,
one for each define-logger. Lastly, #1 is what I'm trying to avoid :)
To be fair, either #1 or #3 is fully *practical*, but the Racketeer in me
would prefer to fully automate this. The "proper" solution seems to require
a Racket change.
Is #3 a bug? Or I might be getting confused at the timing with the
define-logger = current-logger being used to write the log and the
interceptor reverting to the previous logger, but the code that seems like
it should work here:
#lang racket/base
(require racket/logging)
(define-logger x)
;works, no define-logger topic though
(let ([thread-id "hurray"])
(with-intercepted-logging
(λ (v)
(printf "~a: ~a~n" thread-id (vector-ref v 1)))
(λ ()
(log-debug "we interrupt this program to bring you this important
message"))
'debug))
;doesn't work
(let ([thread-id "hurray"])
(with-intercepted-logging
(λ (v)
(printf "~a: ~a~n" thread-id (vector-ref v 1)))
(λ ()
(log-x-debug "we interrupt this program to bring you this important
message"))
'debug))
;works but messy for many define-loggers
(let ([thread-id "hurray"])
(with-intercepted-logging
#:logger x-logger
(λ (v)
(printf "~a: ~a~n" thread-id (vector-ref v 1)))
(λ ()
(log-x-debug "we interrupt this program to bring you this important
message"))
'debug))
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.