crossbar
crossbar copied to clipboard
Log should be more forgiving for byte arrays
When feeding byte arrays into the log from a worker process - we get to module: crossbar.controller.processtypes and method WorkerProcess.log. Here the byte array is decoded with UTF-8. I think this is a too strong assumption for a log message and would suggest in line 191:
if type(data) != six.text_type:
data = data.decode('utf8', 'replace')
cleaning up issues .. a lot has changed since, however, logging is for logging of strings, and the caller is responsible for type conversion
Since the stdout is redirected and some deeply nested foreign hardware controlling modules (like in our case) sometimes just print messages I still believe it could be useful to include this little "replace" parameter. I'm a great fan of your protocol/framework but I always have to forward-port this little piece of code when I update ...
sure, having to use some 3rd party lib that doesn't do it right, I see. anyways, it is cheap/non-invasive to add some guards in crossbar logging as you hint ..