strongloop / node-foreman

A Node.js Version of Foreman
http://strongloop.github.io/node-foreman/
Other
1.27k stars 119 forks source link

Trimming clears output colorisation #99

Closed fiznool closed 6 years ago

fiznool commented 8 years ago

I'm using winston to log messages to the console. When using the --trim option, if the line is trimmed, colors are lost.

See screenshot:

screenshot from 2016-03-30 10-45-35

Notice that the info text is colorised correctly in the first case, but not when --trim has trimmed the lines.

jdx commented 8 years ago

That's because winston disables the colors when it is not connected to a tty. This isn't an issue with node-foreman.

fiznool commented 8 years ago

Why does this only occur when the output is trimmed? If Winston disables colours in non tty environments, I would have thought colours would be hidden in both scenarios above.

jdx commented 8 years ago

oh sorry! ignore my previous comment. I think this is why: https://github.com/strongloop/node-foreman/blob/master/lib/console.js#L27

Probably what needs to happen is to determine how long the string is sans-ascii-escapes and trim based on that.

fiznool commented 8 years ago

Yes that looks like the issue! If I get any time I'll try to put together a PR which solves this.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.