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

NO_COLOR, and --no-color options change logging format #4510

Open
oleiade opened this issue Feb 4, 2025 · 0 comments
Open

NO_COLOR, and --no-color options change logging format #4510

oleiade opened this issue Feb 4, 2025 · 0 comments
Labels

Comments

@oleiade
Copy link
Member

oleiade commented Feb 4, 2025

Brief summary

I've noticed while working on integrating k6-jslib-testing that both the --no-color flag and the NO_COLOR environment variables when used, do disable colors, but also changes the logging format of console.log.

The following script:

export default function main() {
    console.log("\x1b[31mhello\n\x1b[0mworld!"); // ANSI codes marking hello as red color
}

Ran with k6 run script.js results in the following output:
Image

But ran with NO_COLOR k6 run script.js or k6 run --no-color script.js results in the following output: Image

Whereas I would have expected for the output to be aligned with the colored one, just, without colors:

INFO[0000] hello
world!                         source=console

Maybe this was the intended behavior, and there might be justifications for it being this way. But as it didn't align with my expectations and assumptions as a user, and I couldn't find more context about this besides the initial PR for NO_COLOR, I thought I would still open a bug to give a shot at addressing that, or at the bottom line, document why it works this way.

k6 version

v0.56.0

OS

macOS

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Script:

export default function main() {
    console.log("\x1b[31mhello\n\x1b[0mworld!");
}

Command:

k6 run --no-color script.js

Expected behaviour

INFO[0000] hello
world!                         source=console

(not colorized)

Actual behaviour

time="2025-02-04T12:42:24+01:00" level=info msg="\x1b[31mhello\n\x1b[0mworld!" source=console
@oleiade oleiade added the bug label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant