ether / etherpad-lite

Etherpad: A modern really-real-time collaborative document editor.
http://docs.etherpad.org/
Apache License 2.0
16.71k stars 2.85k forks source link

Disable colors in logs #5303

Closed markand closed 3 months ago

markand commented 2 years ago

name: Disable colors in logs about: Disable colors in logs title: 'Disable colors in logs' labels: enhancement


Is your feature request related to a problem? Please describe.

On FreeBSD I use /usr/sbin/daemon which redirects all output from stdout,stderr to syslog, it looks like etherpad (or the logging) module does not detect that the file descriptors are not tty and the ANSI escapde code persist so logs are full of them.

Example:

$ cat /var/log/messages
[...]
Nov 26 08:47:36 pad daemon[17464]: ^[[32m[2021-11-26 08:47:36.202] [INFO] Minify - ^[[39mCompress JS file /var/srv/pad/src/static/js/undomodule.js.
Nov 26 08:47:36 pad daemon[17464]: ^[[32m[2021-11-26 08:47:36.257] [INFO] Minify - ^[[39mCompress JS file /var/srv/pad/src/static/js/ace2_inner.js.
Nov 26 08:47:36 pad daemon[17464]: ^[[32m[2021-11-26 08:47:36.526] [INFO] Minify - ^[[39mCompress JS file /var/srv/pad/src/static/js/domline.js.

Describe the solution you'd like

An option to disable coloring output entirely. I was unable to find one in the settings.json.template nor in the wiki documentation.

laurivosandi commented 1 year ago

I am also annoyed by this

heldersepu commented 4 months ago

We are using log4js:

https://github.com/ether/etherpad-lite/blob/a63792116007a941eabe735bd843555cc95a1299/src/node/hooks/express/adminplugins.ts#L12-L13

https://github.com/ether/etherpad-lite/blob/4192b428fe373ee4e48336cc6f09cdf8751d13e1/src/node/hooks/express/openapi.ts#L29-L30

If they have that option we can look into adding it, researching that now

heldersepu commented 4 months ago

https://github.com/log4js-node/log4js-node/issues/112#issuecomment-13061075

Put this somewhere in your code before you start logging: log4js.configure({ appenders: [ { type: "console", layout: { type: "basic" } } ], replaceConsole: true })

If we have to add that to every file that will be a pain

heldersepu commented 4 months ago

Here is another: https://github.com/log4js-node/log4js-node/issues/728#issuecomment-395644924

"console": { "type": "console", layout: { type: "basic" } }

that seems to go in a config file, but we do not have one... 🤔

heldersepu commented 4 months ago

Maybe this is the place:

https://github.com/ether/etherpad-lite/blob/d202ccd178df5c486972ff478b75333a576bd624/src/node/utils/Settings.ts#L55-L80

SamTV12345 commented 4 months ago

Maybe this is the place:

https://github.com/ether/etherpad-lite/blob/d202ccd178df5c486972ff478b75333a576bd624/src/node/utils/Settings.ts#L55-L80

Yes seems like that. Are you up for a pr for that. Maybe add an option to settings.json file?

heldersepu commented 3 months ago

Confirmed that is the place ... looking for a way to integrate with the settings

heldersepu commented 3 months ago

@SamTV12345 please take a look at the PR when you get a chance