Commit 95d7e390 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

review: consider removing putStrLn

parent 9dfec964
......@@ -72,3 +72,20 @@ src/Async/Worker.hs:277:22: error: [-Wredundant-constraints, -Werror=redundant-c
As the name implies, `Debug.Trace` & co are really only for debugging purposes, and is not recommended
to leave them in library code, `traceStack` being a primary example.
# Remove calls to `putStrLn`; Consider adding a \"pluggable\" tracing mechanism
At the moment errors and other events are simply printed to stdout, which is not very ideal for a few reasons:
* They gets interleaved with normal output (including test runs), making output garbled;
* The user is not given a choice how to separate normal logging (on stdout) vs errors (typically on `stderr`,
which is not the case here); maybe users would rather be interested to see errors elsewhere (example: a log file);
* Logging can't be disabled or filtered, which might be useful in some contexts.
There are ways to solve this; the classic approach is to simply pick a logging library of choice and stick with
it; the mode modern/scalable approach is using inversion of control for adding contravariant tracing in the vein
of [contra-tracer](https://hackage.haskell.org/package/contra-tracer-0.2.0.0/docs/Control-Tracer.html) or
[co-log](https://hackage.haskell.org/package/co-log). In this style the broker (or the functions using the
broker, your mileage might vary) would gain an extra parameter (like a `Tracer` if using contra-tracer) and
then it's up to the caller to pick the concrete implementation for the logger, and the library would use
the opaque interface (that's the simplified TL;DR).
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment