Etherpad-lite: Etherpad shouldn't print terminal sequences into the file log

Created on 31 May 2015  ·  8Comments  ·  Source: ether/etherpad-lite

You need to only print terminal sequences when the output is an actual terminal.

Minor Bug

All 8 comments

Please elaborate

On 31 May 2015 05:36, yurivict [email protected] wrote:

You need to only print terminal sequences when the output is an actual terminal.


Reply to this email directly or view it on GitHubhttps://github.com/ether/etherpad-lite/issues/2685.

When piped to file, log looks like this

Started Etherpad...
^[[33m[2015-05-30 21:26:58.721] [WARN] console - ^[[39mDirtyDB is used. This is fine for testing but not recommended for production.
^[[32m[2015-05-30 21:27:00.402] [INFO] console - ^[[39mInstalled plugins:
^[[32m[2015-05-30 21:27:00.439] [INFO] console - ^[[39mReport bugs at https://github.com/ether/etherpad-lite/issues
^[[32m[2015-05-30 21:27:00.442] [INFO] console - ^[[39mYour Etherpad version is 1.5.6 (b049f4b)
^[[32m[2015-05-30 21:27:00.622] [INFO] console - ^[[39mYou can access your Etherpad instance at http://0.0.0.0:9001/
^[[33m[2015-05-30 21:27:00.622] [WARN] console - ^[[39mAdmin username and password not set in settings.json.  To access admin please uncomment and edit 'users' in settings.json

Sounds like a log4js bug? We use that...

On 31 May 2015 10:46, yurivict [email protected] wrote:

When piped to file, log looks like this

Started Etherpad...
^[[33m[2015-05-30 21:26:58.721] [WARN] console - ^[[39mDirtyDB is used. This is fine for testing but not recommended for production.
^[[32m[2015-05-30 21:27:00.402] [INFO] console - ^[[39mInstalled plugins:
^[[32m[2015-05-30 21:27:00.439] [INFO] console - ^[[39mReport bugs at https://github.com/ether/etherpad-lite/issues
^[[32m[2015-05-30 21:27:00.442] [INFO] console - ^[[39mYour Etherpad version is 1.5.6 (b049f4b)
^[[32m[2015-05-30 21:27:00.622] [INFO] console - ^[[39mYou can access your Etherpad instance at http://0.0.0.0:9001/
^[[33m[2015-05-30 21:27:00.622] [WARN] console - ^[[39mAdmin username and password not set in settings.json. To access admin please uncomment and edit 'users' in settings.json


Reply to this email directly or view it on GitHubhttps://github.com/ether/etherpad-lite/issues/2685#issuecomment-107150769.

This same issue came up with git ~6 mo ago, in relation with pager. You might want to look up that discussion in archives. I remember this was very tough to guess if pager can handle colors. They ended up insisting on colors, but involved guess work makes system error prone. No general way to do this accurately.

You need to either go this hard way. Or just disable colors when output isn't the terminal, which is 100% easy.

I'd accept a pull request if you have an easy fix

Now when I looked, you have a lot of copy-pasted code with terminal sequences.
You need to use some standard js package (like this one https://github.com/sindresorhus/chalk) Then either this package will handle printing correctly, or it will be easy to fix it. But not with the current hard-coded style.

@yurivict See #2835

One solution might be to look at this in reverse: only render in colour if requested to do so.

Was this page helpful?
0 / 5 - 0 ratings