@greg @soegaard2 Thanks guys, just what I need.
if i want log messages (from log-info
etc.) to have a custom format (timestamps, etc.), what’s the best way to do that?
@jjwiseman where should this custom format appear?
to start, could it be “the default”? that is, say the only change i want to make is to add a timestamp?
I think the shortest answer is you can’t
The next shortest answer is that you can write your own log reciever that gets the log events and prints them however it wants
But the log reciever that is run at startup isn’t configurable
(at least, I don’t think it is)
are there good (production) examples of doing that? e.g. it would seem that i’d need to wrap my main in a dynamic-wind
to make sure log messages get displayed/handled in the case of an exception.
and there are probably other issues i’m not aware of.
I think @greg has mentioned having some production examples of logging to an AWS service
(i.e. (dynamic-wind ... ... (lambda () (drain-log-message-queue))
or something)
@jjwiseman I think dynamic-wind
shouldn’t be necessary regardless, since log messages are sent and received asynchronously
I imagine instead at program startup time you’d start a thread
that receives logs and processes them before sending them somewhere like stderr or syslog or whatever cloud logging service you’re using
it’s because of the asynchronicity that i think it is needed… without it, i may not even see the log messages that preceded a program-killing exception.
(usually those are the most interesting log messages, so you don’t want to miss them :slightly_smiling_face: )
i don’t think it even requires an exception to see weird behavior—if the last thing my program does before exiting is (log-error "woo")
, i probably wouldn’t/might not see it.
(unless i’m missing something?)
@jjwiseman IIRC I used a plumber to flush the log-receiver and that seemed to work.
Also, I was “batching” logger messages, waiting until I had N or X seconds elapsed, before doing the AWS put to CloudWatch HTTP request. I think that was my main motivation for the plumber, to handle even just a graceful exit, or a break. So maybe it doesn’t help with an exception exit? But I think it would??
ah, thanks, hadn’t known about plumbers.
(i also did the batching thing. i’d be curious to see your implementation. mine is https://gist.github.com/wiseman/5d6fa929bf71925a577d48d220feb30c)