rustler icon indicating copy to clipboard operation
rustler copied to clipboard

println! with iex -S mix produces poorly formatted output

Open vans163 opened this issue 5 years ago • 5 comments
trafficstars

image

It looks like this basically.

vans163 avatar Nov 03 '20 15:11 vans163

Not much we can do about this I believe.

An alternative would be to introduce a new printing function in rustler that uses the BEAM provided printing functions.

Relevant: https://github.com/rusterlium/rustler/issues/72

hansihe avatar Nov 03 '20 16:11 hansihe

There is this, which could enable us to change where the default rust print functions send their outputs. This seems to be what the rust test framework uses.

The issue is I don't think there is any way for us to statically execute code on every scheduler thread, so I don't think we can actually use this.

https://github.com/rust-lang/rust/blob/db15596c5747eed0344f2622a9d85ad9534b23f9/library/std/src/io/stdio.rs#L934-L963

hansihe avatar Nov 03 '20 22:11 hansihe

FWIW, I've had pretty good luck using env_logger: https://github.com/scrogson/franz/blob/master/native/franz/src/lib.rs#L12

scrogson avatar Nov 04 '20 00:11 scrogson

The set_print is also unstable. Maybe we should just document that using print! etc. is a bad idea and people should use the log crate instead.

filmor avatar Nov 04 '20 09:11 filmor

I am using the env_logger crate and am still having this behavior. Is this expected? (ie does this issue go deeper into the rust/erlang logging interaction). If its not expected, is there a code example that might be able to get logging output without the extra spaces? Are there any known workarounds? (for example syslog)

cannadayr avatar Sep 01 '21 14:09 cannadayr