Package: https://pkgs.racket-lang.org/package/in-out-logged
Wraps a chunk of code in "entering" and "leaving" log messages, returns the value(s) produced by the code. Example: Keyword arguments are all optional. #:to and #:at may appear in either order but #:with must come last if it is present. (define-logger foo) (define (on-complete op . args) (log-foo-debug "in on-complete") (apply op args)) (in/out-logged ("on-complete" #:to foo-logger #:at 'debug ; NB: This is the default so it could be omitted "time" (current-inexact-milliseconds)) (on-complete + 1 2 5)) (in/out-logged ("values" #:at 'error ; NB: Goes to (current-logger) since #:to not given. Has 'error priority #:with "time is: ~a, username is: ~a." (current-inexact-milliseconds) 'bob) (values 1 2)) Produces: foo: entering on-complete. args: time 1631134220582.874 foo: in on-complete foo: leaving on-complete. args: time 1631134220582.874 8 entering values. time is: 1631134385090.149, username is: bob. leaving values. time is: 1631134385090.161, username is: bob. 1 2 With thanks to Martin DeMello and Sorawee Porncharoenwase for suggestions on syntax and functionality. TODO: Better formatting of the arguments. (in/out-logged ("name" #:to foo-logger #:at 'info #:with "args are: ~a ~a" ' arg1 'arg2) code ...) -- 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 racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAE8gKocMnqcQVw31SQjUqaSoFmZS9TDSy1%2ByT9yf25Py6VmN%3DQ%40mail.gmail.com.