8.18
top
← prev up next →

Intercepted LoggingπŸ”— i

:
(->* [(-> A)]
[#:level(or/c log-level/c #f)
#:topic(or/c symbol? #false)]
(values A
(hash/c log-level/c any/c #:immutable#true#:flat?#true))))
A log interceptor for the logger L is a procedure that executes a thunk and returns two values:
  1. the result of the thunk

  2. a hash of all events logged to L during the thunk, organized by log level.

The optional arguments help filter the log events. If #:level is given, then the returned hash only contains events for the given level and higher levels. If #:topic is given, then the returned hash only contains events with the given topic. The default level is 'info and the default topic is the value of (logger-name L).

See also: with-intercepted-logging

logger:logger?
Makes a log interceptor for the given logger.

Examples:
> (define ricardo(gensym 'ricardo))
> (define-logger ricardo)
> (define rick-interceptor(make-log-interceptor ricardo-logger))
> (define (fx)
(when (eq? xricardo)
(log-ricardo-info"f spotted a ricardo"))
(void ))
> (define-values [f-resultf-logs]
(rick-interceptor
(lambda ()
(fricardo)
(f'fish)
(fricardo))))
> f-logs

'#hasheq((debug . ())

(error . ())

(fatal . ())

(info

.

("ricardo: f spotted a ricardo" "ricardo: f spotted a ricardo"))

(warning . ()))

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /