I am trying to wrap some logging procedures into macros. I have a logger
for my application which I define as:

(define-logger sap)

Then I want to define a macro that possibly receives an extra argument
which is the part of the application that's issuing the logging message.

So, if logging from parser, the message would be something like:
sap:parser: msg...

So, I have:
(define-syntax (lt/log stx)
  (syntax-case stx (quote)
    [(_ (quote component) (quote level) msg v ...)
     (with-syntax ([name (datum->syntax stx
                                       (format "log-sap-~a" (quote
(syntax->datum #'level))))])
       #'(name (format (string-append (symbol->string (quote component))
                                      ": "
                       v ...)))]
    [(_ (quote level) msg v ...)
     (with-syntax ([name (datum->syntax stx
                                       (format "log-sap-~a" (quote
(syntax->datum #'level))))])
       #'(name (format msg v ...)))]))

The reason I am using (quote component) and (quote level) in the
template is because if I don't, then I get all sorts of issues with
messages being matched to the wrong syntax case template.

On the other hand, with this kind of macro the with-syntax doesn't seem
to be working so well when doing (format "log-sap-~a" (quote
(syntax->datum #'level))) because of the whole mess I created in the
template with the quote.

How can I properly write this macro such that it's properly matching the

kind regards,
Paulo Matos

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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to