crossbario / crossbar

Crossbar.io - WAMP application router
https://crossbar.io/
Other
2.05k stars 274 forks source link

Log should be more forgiving for byte arrays #1241

Open blinkingmatt opened 6 years ago

blinkingmatt commented 6 years ago

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')
oberstet commented 2 years ago

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

blinkingmatt commented 2 years ago

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

oberstet commented 2 years ago

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