On 1/31/2018 5:00 PM, Alexander McLin wrote:
During the tool's start up period prior to calling the main function I
set up a log receiver to receive messages at the desired level and
place it inside a sync loop within its own thread. Each time a sync
event is received, it is written out to the port, then loop back to
waiting for the next sync event.
It works reasonably well except I have a new problem, when the tool
exits, it often exits before the thread handling the log receiver
propagation to the port has finished receiving all the log events, as
a result my logging output is frequently truncated.
Given this undesired situation, I need to figure out a better way to
reliably propagate all log messages to ports before the tool exits
normally or due to a raised exception.
There may be a better way, but I handle this kind of thing with
dynamic-wind. The program's main function looks like
(start
:
(dynamic-wind
(lambda ()
;;; startup services
... )
(lambda ()
;;; program's purpose
... )
(lambda ()
;;;shutdown services
... )
)
:
)
There is `with-logging-to-port` except I will need to set up multiple
ports and the idea of wrapping the tool's main body with multiple
`with-logging-to-port` for each port isn't appealing and it still
doesn't resolve the problem.
I use with-logging-to-port in the individual logger threads to direct
their output. I don't wrap it around all the code.
I was wondering if anyone has a better suggestion? Is there a way to
detect if there are pending log events waiting to be received by the
log receiver?
Not that I know of, but if you structure the logger so that it must be
specifically shut down, you can drain the message queue before terminating.
George
--
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.