Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moleculer prints colored log messages when colored log messages are disabled #793

Closed
4 tasks done
oliversalzburg opened this issue Aug 12, 2020 · 4 comments
Closed
4 tasks done

Comments

@oliversalzburg
Copy link
Contributor

oliversalzburg commented Aug 12, 2020

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository

Current Behavior

Certain log messages are colored, even though colored log messages have been disabled.

{"level":40,"time":1597228317296,"pid":21927,"hostname":"oliver-work","msg":"\u001b[33m\u001b[1mRedis Discoverer is an EXPERIMENTAL module. Do NOT use it in production!\u001b[39m\u001b[22m"}

Expected Behavior

When colored log messages are disabled, log messages are not colored.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Enable the Redis Discoverer
  2. Disable colors in the logger
  3. Start the application

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Moleculer version: 0.14.8
  • NodeJS version: 14
  • Operating System: Windows

My logger configuration:

logger : {
	type : "Console",
	options : {
		colors : false,
		formatter : ( level, logElements, bindings ) => logElements
	}
},
@oliversalzburg
Copy link
Contributor Author

Seems like I missed a part of our code where the logger is replaced by our own implementation.

The color is already hardcoded into the log message. The colors property of the ConsoleLogger refers to the coloring of entire log lines by that logger. But that logger isn't even used in our setup.

@NickLarsenNZ
Copy link

NickLarsenNZ commented Oct 14, 2021

I think this should still be an open issue. Something in moleculer is causing those control characters to come through, but I'm not sure where they're from.

{"level":"info","message":"  \u001b[35m   GET\u001b[39m \u001b[36m/api/openapi/:spec/:format\u001b[39m\u001b[90m => \u001b[39mopenapi.schema","mod":"api","nodeID":"computer-27240","ns":"","svc":"api"}

That results in a lot of unnecessary eye-candy, and becomes confusing when the service is busy and logs lines become interleaved:

image

@icebob
Copy link
Member

icebob commented Oct 14, 2021

It can be related to #941

@NickLarsenNZ
Copy link

I only had a single logger.

After further digging around, I jumped over to moleculer-web and see this comment: moleculerjs/moleculer-web#213 (comment)

FORCE_COLOR=0 does exactly what I needed 👍 hope it helps others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants