8.16.0.1
Intercepted Logging
(require make-log-interceptor) | |
package: make-log-interceptor |
contract
:
(parametric->/c [A] (->* [(-> 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))))
the result of the thunk
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
procedure
(make-log-interceptor logger) → log-interceptor/c
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 (f x) (when (eq? x ricardo) (log-ricardo-info "f spotted a ricardo")) (void))
> (define-values [f-result f-logs] (rick-interceptor (lambda () (f ricardo) (f 'fish) (f ricardo)))) > f-logs
'#hasheq((debug . ())
(error . ())
(fatal . ())
(info
.
("ricardo: f spotted a ricardo" "ricardo: f spotted a ricardo"))
(warning . ()))