crossbar icon indicating copy to clipboard operation
crossbar copied to clipboard

Log should be more forgiving for byte arrays

Open blinkingmatt opened this issue 7 years ago • 3 comments

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')

blinkingmatt avatar Jan 12 '18 13:01 blinkingmatt

cleaning up issues .. a lot has changed since, however, logging is for logging of strings, and the caller is responsible for type conversion

oberstet avatar Mar 31 '22 03:03 oberstet

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

blinkingmatt avatar Mar 31 '22 07:03 blinkingmatt

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

oberstet avatar Mar 31 '22 08:03 oberstet