-
Notifications
You must be signed in to change notification settings - Fork 6
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
Enabled colorization #42
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is partially correct. We should mimic the behavior of pino-pretty, where colorization is enable if there is a human being attached (a TTY), and disable it if the output goes to a file etc. Check out pino-pretty.
Hey @mcollina, sure. |
I think we could expose it in pino-pretty, and then use it here from there. |
@mcollina could you give me a review on this one: pinojs/pino-pretty#513 |
Hi @mcollina, I wanted to let you know that I have made a new commit that includes a check for the presence of colors in TTY, which is set to |
pino-pretty v11.1.0 is out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I've pulled this and it does not seem to work. If I redirect the output to a file, the colors are still there. |
Hey @mcollina just a quick question, were you running this from your local bash? I'm guessing const isDisabled = "NO_COLOR" in env || argv.includes("--no-color")
const isForced = "FORCE_COLOR" in env || argv.includes("--color")
const isWindows = platform === "win32"
const isDumbTerminal = env.TERM === "dumb"
const isCompatibleTerminal =
tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal
const isCI =
"CI" in env &&
("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env)
export const isColorSupported =
!isDisabled &&
(isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI) Do you have any suggestions on how to know, from inside the logger formatter, what will be the outcome of the log (file, std or else)? I'm am guessing this should also overwrite the |
running the process with |
From the |
Maybe. I'm pretty happy with how pino-pretty work, I need to do some checks first, as I might have been too quick on my last test. |
Hey folks, just a quick note here, after discussing offline with @synapse . In order to figure out how existing tools handle it, we checked out jest and here's what we found.
So we started looking into how jest does it, and we discovered that:
|
Hey @mcollina any news on this? |
Hey @mcollina, The Here's a summary of our current status to help us decide the next steps:
Unfortunately, color detection in To automatically disable the output of UTF-8 color strings when not needed, we should address this issue in either the What do you suggest as the best steps moving forward? |
It doesn't seem we are in the same page. I see that the |
@mcollina I've updated the PR with the changes and also added it in the docs |
linting is failing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
fixes #35
Checklist
npm run test
andnpm run benchmark
and the Code of conduct