phpMqttClient
phpMqttClient copied to clipboard
Add debug output using a PSR3 logger
As discussed in #31, echoing is not that great for providing debug output.
This PR introduces a $logger parameter to the ClientFactory that is passed through to the MqttClient. The $logger provided should conform to the PSR3 LoggerInterface. I have done a bit of manual testing with https://github.com/WyriHaximus/reactphp-psr-3-stdio and that worked. Small example:
$loop = $client->getLoop();
$logger = StdioLogger::create($loop);
$client->setLogger($logger);
The MqttClient currently uses a private function debug() to log the messages that were echoed at the debug level.
@oliverlorenz What do you think of this? Now that I see it again, I see that the dependency is not optional, but I could make it like that.