d_run
2018-5-13 14:12:22

question about logging, if I define a logger with (define-logger foo) in main.rkt how do I make loggers like (log-foo-info ...) available to other procs in modules called by main.rkt?


greg
2018-5-13 14:22:24

@d_run I typically put that in a logger.rkt that main.rkt and other modules would require.


d_run
2018-5-13 14:22:58

and they’re just made available or do I need to provide them?


greg
2018-5-13 14:24:16

You’d need to provide them. They’re just functions. There’s no handy provide-all-of-them-in-one-expression.


greg
2018-5-13 14:24:27

Either provide them one by one or maybe use all-defined-out


d_run
2018-5-13 14:24:35

ah ok ok - lemme try that out


greg
2018-5-13 14:25:31

(A logger.rkt is where I’d put other fun such as setting current-trace-notify and friends to procs that shuttle traces to log-xxx-debug. Or shipping logs to AWS CloudWatch Logs or similar service.)


greg
2018-5-13 14:26:48

But yeah, maybe someone should make a tiny package — or submit a PR to racket itself — that augments define-logger with a define/provide-logger.


d_run
2018-5-13 14:35:54

ah that worked great


d_run
2018-5-13 14:36:17

i always get tripped up with logging - not a lot of examples out there


d_run
2018-5-13 14:47:00

btw nice protip from your article on using JSON formatted logging with AWS


ben
2018-5-14 03:52:05

this reminds me — I have a function that accepts a logger and returns a function that collects the messages to that logger. Now its a package: https://github.com/bennn/make-log-interceptor