Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug output using a PSR3 logger #35

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hslatman
Copy link

@hslatman hslatman commented Feb 8, 2019

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.

…on issue

Injecting the $logger through ClientFactory would result in an error
in the React\Dns\Resolver\Factory.php file.

In Factory.php line 90:

  [ErrorException]
  Warning: strpos() expects parameter 1 to be string, object given

I haven't bothered too much with finding out what the problem is here.
@hslatman
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant