commercialhaskell / rio

A standard library for Haskell
Other
838 stars 54 forks source link

Crash when using log func with no attached console on windows #207

Closed jeiea closed 4 years ago

jeiea commented 4 years ago

Following snippets are not accurate, just for description.

# package.yaml ...
ghc-options:
  - -optl-Wl,--subsystem,windows
-- Main.hs
main = do
  logOptions <- logOptionsHandle stderr False
  withLogFunc logOptions $ \lf -> do
      let app = App { logFunc = lf }
      runRIO app eventLoop

image

If there was console window, no error appeared. How about disable log in this situation? It's consistent with Prelude behavior.

snoyberg commented 4 years ago

It seems to me like the current behavior is preferable. I'd rather an error occur than logs silently going missing. In a situation like this, you can set mempty as the log function to explicitly turn it into a noop.