I'm currently working on an application that uses structured logs (JSON) instead of the traditional string formatted logs. I currently have a log message handler based on some work Greg Hendershott put together:
``` (define (handle-log-message receiver) (λ (out) (match (sync receiver) [(vector event-level event-message event-value name) (displayln (jsexpr->string (hasheq 'timestamp (date->string (current-date) #t) 'level ((compose string-upcase symbol->string) event-level) 'msg (regexp-replace #rx"(^[a-z]*): " event-message "") 'name (symbol->string name))) out)]))) ``` When I setup a log-writer this works well with simple logs like ``` (log-app-info "START") ``` Which will emit a log entry such as: ``` {"msg":"START","level":"INFO","name":"log-name","timestamp":"2019-03-30T18:27:29"} ``` However, I would like to pass a jsexpr? to the logger, such as `(log-app-info (hasheq 'tags '("a" "b" "c")))` to get a log entry such as: ``` {"msg": {"tags": ["a", "b", "c"]},"level":"INFO","name":"log-name","timestamp":"2019-03-30T18:27:29"} ``` This is pretty common when working with AWS and other log services and is something I do at work with a Python lib (https://www.structlog.org/en/stable/) As far as I can tell, the log procs only accept strings. Would l need to convert my log message into a JSON string, then in the log handler convert it back into a jsexpr? and then back into a string? If that is the case is it possible to wrap the the `(log-<log name>-<level>)` procs in a macro to automate this? Thanks in advance for any tips -- 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.