I have program where I’m using hlogger next way, I have main thread and arbitrary number of workers thread, wich one should write logs into separate file. So I’m using:
s <- openlog ..
updateGlobalLogger ("myapp."++threadId) (addHandler s)
But it seems that this way will consume a log of memory for storing handlers for threads
and I’ve found to way to dispose this information at the end of thread work.
Can somebody advice better way of storing info or a way to free memory.
If you’re concerned about
Handles being left open after each thread is finished, you can wrapforkIOin a helper that will create the handler you want, run the thread with the right log name, and then close the handle afterwards:Update: now handles exceptions properly.