mqtt-hs
mqtt-hs copied to clipboard
Logging capabilities in callbacks
The return type of a SimpleCallback
and OrderedCallback
is IO ()
. These IO
actions are subsumed in the IO MQTTClient
return type of connectURI
. However, the user might want to perform different action depeding on the content of a message, e.g. log messages upon receiving malformed messages.
It would be a major overhaul, but very useful, if net-mqtt provided a mechanism for structured error handling and reporting. For example, the MQTTClient
type could expose a TChan
that callbacks can write to and ambient applications can read from, so that worker threads and the ambient application can exchange messages in a structured way.
This sounds like what the mqtt-watch callback does. For each inbound message, the message is sent to a tchan where it can be picked up by a thread that logs the message..