From errge:
From errge:

Hi,

Test code:

import Control.Concurrent
import Control.Monad
import System.Log.Logger

main = do
  updateGlobalLogger rootLoggerName (setLevel DEBUG)
  mainThread <- myThreadId
  _ <- forkIO $ forever $ do
    killThread mainThread
    threadDelay 1
  forever $ logM "" INFO "foobar"

Running this after compilation like this, shows that killing a thread that is in a logging function right now is not stable:

ghc --make test && ./test 2>&1 | uniq -c

   1 Error writing log message: thread killed (original message: foobar)
1116 foobar
   1 fooError writing log message: thread killed (original message: foobar)
2569 foobar
   1 Error writing log message: thread killed (original message: foobar)
1717 foobar
   1 fError writing log message: thread killed (original message: foobar)
3515 foobar
   1 foobarError writing log message: thread killed (original message: foobar)
3438 foobar
   1 foError writing log message: thread killed (original message: foobar)
3400 foobar
   1 test: thread killed

This is because streamHandler catches all the exceptions, even async ones. This is totally discouraged and results in errors like this.

After my patch:

$ ghc -fforce-recomp --make test && ./test 2>&1 | uniq -c
[1 of 1] Compiling Main             ( test.hs, test.o )
Linking test ...
      1 test: thread killed

Please consider including this patch, thanks!

Further info: http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception.html#g:4

closes #8

jgoerzen/hslogger