Open yidayoung opened 3 years ago
when print a record like #rec{field =<<"">>}, it will trans to string "#rec{field=<<"">>}" every thing works fine, but when paste this string to shell will cause syntax error before: '=<' because need space after '=' like this "#rec{field= <<"">>}"
#rec{field =<<"">>}
syntax error before: '=<'
so, can we change this format here
https://github.com/erlang-lager/lager/blob/459a3b2cdd9eadd29e5a7ce5c43932f5ccd6eb88/src/lager_trunc_io.erl#L501-L504
one way is change binary print function
https://github.com/erlang-lager/lager/blob/459a3b2cdd9eadd29e5a7ce5c43932f5ccd6eb88/src/lager_trunc_io.erl#L130-L148 but this may cause some other behavior changed
or just add ensure_space after print function, like this
{FieldStr, FieldLen} = print(Field, Max - ExtraChars, Options), {ValueStr, ValueLen} = print(Value, Max - (FieldLen + ExtraChars), Options), {ValueStr2, ValueLen2} = ensure_space(Value, ValueStr, ValueLen), {Final, FLen} = record_fields(T, Max - (FieldLen + ValueLen + ExtraChars), dec_depth(Options)), {[FieldStr++"="++ValueStr2++Terminator|Final], FLen + FieldLen + ValueLen2 + ExtraChars}. ensure_space(Value, ValueStr, ValueLen) when is_binary(Value) -> {" "+ValueStr, ValueLen+1}; ensure_space(_Value, ValueStr, ValueLen) -> {ValueStr, ValueLen}.
if add ensure_space is enough, i can make a pr for this
ensure_space
when print a record like
#rec{field =<<"">>}
, it will trans to string "#rec{field=<<"">>}" every thing works fine, but when paste this string to shell will causesyntax error before: '=<'
because need space after '=' like this "#rec{field= <<"">>}"so, can we change this format here
https://github.com/erlang-lager/lager/blob/459a3b2cdd9eadd29e5a7ce5c43932f5ccd6eb88/src/lager_trunc_io.erl#L501-L504
one way is change binary print function
https://github.com/erlang-lager/lager/blob/459a3b2cdd9eadd29e5a7ce5c43932f5ccd6eb88/src/lager_trunc_io.erl#L130-L148 but this may cause some other behavior changed
or just add ensure_space after print function, like this
if add
ensure_space
is enough, i can make a pr for this