We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
4.6.16
Cloudflare Workers
Use the default logger middleware provided by Hono https://hono.dev/docs/middleware/builtin/logger
Observe that emitted logs contain ANSI escape sequences when the output is not a TTY:
This screenshot is taken from Cloudflare Workers logs, but the same would be true for any log output which is not a terminal.
Hono should check that stdout is a TTY when determining whether or not to emit ANSI escape sequences for colors:
hono/src/utils/color.ts
Lines 13 to 26 in 2ead4d8
In Node this can be done with Boolean(process.stdout.isTTY) === true https://nodejs.org/api/tty.html#tty
Boolean(process.stdout.isTTY) === true
Deno has Deno.stdout.isTerminal() https://docs.deno.com/api/deno/~/Deno.stdout.isTerminal
Deno.stdout.isTerminal()
No response
A workaround in the meantime is to set NO_COLOR manually if stdout is not a TTY:
NO_COLOR
if (Boolean(process.stdout.isTTY) === false) { process.env["NO_COLOR"] = "1" }
Note however that even this will not work in Cloudflare Workers because of another issue with the process polyfill: unjs/unenv#380
process
The text was updated successfully, but these errors were encountered:
HI @gpanders
Thank you for raising the issue. There is a similar issue #3751. We have the hacky way, but using checking TTY is a good idea.
Hey @ryuapp! What do you think of checking TTY for the logger?
Sorry, something went wrong.
No branches or pull requests
What version of Hono are you using?
4.6.16
What runtime/platform is your app running on? (with version if possible)
Cloudflare Workers
What steps can reproduce the bug?
Use the default logger middleware provided by Hono https://hono.dev/docs/middleware/builtin/logger
Observe that emitted logs contain ANSI escape sequences when the output is not a TTY:
This screenshot is taken from Cloudflare Workers logs, but the same would be true for any log output which is not a terminal.
What is the expected behavior?
Hono should check that stdout is a TTY when determining whether or not to emit ANSI escape sequences for colors:
hono/src/utils/color.ts
Lines 13 to 26 in 2ead4d8
In Node this can be done with
Boolean(process.stdout.isTTY) === true
https://nodejs.org/api/tty.html#ttyDeno has
Deno.stdout.isTerminal()
https://docs.deno.com/api/deno/~/Deno.stdout.isTerminalWhat do you see instead?
No response
Additional information
A workaround in the meantime is to set
NO_COLOR
manually if stdout is not a TTY:Note however that even this will not work in Cloudflare Workers because of another issue with the
process
polyfill: unjs/unenv#380The text was updated successfully, but these errors were encountered: