commercialhaskell / rio

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

Multi-threaded logging #227

Closed f-f closed 3 years ago

f-f commented 3 years ago

It looks like the logger garbles output when multiple threads write at the same time

This seems to be the relevant code that prints to the console:

https://github.com/commercialhaskell/rio/blob/91c379f29b158dc91e7bea059fe7874d9a16973c/rio/src/RIO/Prelude/Logger.hs#L370-L383

..and it looks like there's no special care for multi-threaded logging (maybe relying on some console behaviour? This seems to happen only in CI in fact, never locally. I am not familiar enough with ttys to answer this)

Should this be considered a bug in the library or is there something we can do about it downstream when consuming the library in order to get ordered log lines? (things like: we could use a single writer thread downstream, but it would make sense for the library to provide this as part of the logging framework, or maybe that's out of the scope, etc)

snoyberg commented 3 years ago

The code is implemented as expected. I'm guessing that the console in question is not set to UTF-8, and that the text package is not handling locking. We'd probably not be interested in implementing any kind of a fix here.

f-f commented 3 years ago

Sounds good, thank you! I'll close then.