phpMqttClient icon indicating copy to clipboard operation
phpMqttClient copied to clipboard

Add debug output using a PSR3 logger

Open hslatman opened this issue 6 years ago • 1 comments

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.

hslatman avatar Feb 08 '19 14:02 hslatman

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

hslatman avatar Feb 15 '19 11:02 hslatman