You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @ryuapp! What do you think of checking TTY for the logger?
It seems like one good idea.
One concern is that some, such as GitHub Actions, don't have a TTY, which makes it difficult to control.
Then someone might ask for FORCE_COLOR and make things complicate.
Hono is generally not executed with GitHub Actions, so the benefits of checking TTY look great for me.
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: