phpMqttClient icon indicating copy to clipboard operation
phpMqttClient copied to clipboard

why does direct echo in processing?

Open andares opened this issue 6 years ago • 3 comments

no debug mode, just echo. You will forced wrap a ob cache to flush echo message when call it in controller.

why do that? I never see a lib force run echo.

andares avatar Nov 17 '18 09:11 andares

Yes, that's just debug information. I was already thinking about removing it. Or we could could add some kind of logger to handle it. I'd be happy to just remove it for now.

jjok avatar Nov 18 '18 23:11 jjok

Feel free to create a PR for that :slightly_smiling: This would be huge improvement for the library.

I wouldn't just remove the echo. To make it right is not that hard, right?

My favourite would be to have logger as optional dependency passed into library. So you are free to choose what ever you want. I remember there was this PSR-3 standard. Is this still the way to go?

oliverlorenz avatar Nov 19 '18 18:11 oliverlorenz

In simple way, you can make a logger callback, and default choose echo in factory.

$client = ClientFactory::createClient(new Version4(), $dns, function ($msg) {
    echo $msg;
});

// user custom
$client = ClientFactory::createClient(new Version4(), $dns, function ($msg) {
    Log::debug($msg);
});

andares avatar Nov 20 '18 03:11 andares