mqtt-hs icon indicating copy to clipboard operation
mqtt-hs copied to clipboard

Logging capabilities in callbacks

Open olafklinke opened this issue 1 year ago • 1 comments

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.

olafklinke avatar Jul 17 '23 15:07 olafklinke

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..

dustin avatar Jul 18 '23 03:07 dustin