I do like the second form better, especially since the actual code being run is not obscured by simply being the last argument to a long log function.
martin On Thu, Sep 2, 2021 at 1:55 PM David Storrs <[email protected]> wrote: > I often find that for debugging I want to see a log message saying "I'm > about to do X" followed by X followed by "I'm done with X" and I want it to > return the result of X. > > I wrote this macro and posted it to the package server: > https://pkgs.racket-lang.org/package/log-bracketed > > In retrospect, the syntax is bad and I should change it. Can anyone > suggest something better? > > (define (on-complete x) (log-test-debug "entering on-complete") x) > (struct person (name) #:transparent) > > (log-bracketed test-debug "on-complete" "time: ~a" (current-seconds) > (on-complete (person 'bob))) > (log-bracketed test-debug "on-complete" "" "no user-specified logging > information") > > Spits out: > > > test: about to on-complete. time: 1630611613 > test: entering on-complete > test: after on-complete. time: 1630611613. result: (person 'bob) > (person 'bob) > test: about to on-complete > test: after on-complete. result: "no user-specified logging information" > "no user-specified logging information" > > > The problem is that this looks like it's a simple logging message when in > fact it's real code that should not be ignored. I'm trying to think of a > better way to do it...maybe something like this?: > > (with-bracketing-logs ([test-debug "on-complete" "time: ~a" > (current-seconds)]) > > (on-complete (person 'bob)) > > > > -- > 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]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/CAE8gKocZha-NpiFAAKT1c8QTG3MDFRnvxCD4T0P269EncZW3KQ%40mail.gmail.com > <https://groups.google.com/d/msgid/racket-users/CAE8gKocZha-NpiFAAKT1c8QTG3MDFRnvxCD4T0P269EncZW3KQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAFrFfuEqt1NVjE2Ft1JVArvWnKUBvK7jPVoLqPhYCd-dB00A3Q%40mail.gmail.com.

