Skip to content

📝 [Proposal]: Force color logging #3400

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

Open
3 tasks done
yorickdewid opened this issue Apr 9, 2025 · 10 comments
Open
3 tasks done

📝 [Proposal]: Force color logging #3400

yorickdewid opened this issue Apr 9, 2025 · 10 comments

Comments

@yorickdewid
Copy link

yorickdewid commented Apr 9, 2025

Feature Proposal Description

Current

At the moment logging with colors is enabled by default (enableColors=true). If certain criteria are met the logger stream is set to NewNonColorable(...), and no color is used in the log output. One of these tests is to see if a TTY terminal is connected isatty.IsTerminal(os.Stdout.Fd()) but there are cases which do support colored output without being connected to a TTY terminal. Examples of these scenarios are:

  • Docker output
  • Kubernetes

Proposal

Either drop the terminal check or introduce a new config option forceColors to enable colors either way.

If either one is accepted I will submit a PR

Alignment with Express API

N/A

HTTP RFC Standards Compliance

N/A

API Stability

N/A

Feature Examples

N/A

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have searched for existing issues that describe my proposal before opening this one.
  • I understand that a proposal that does not meet these guidelines may be closed without explanation.
Copy link

welcome bot commented Apr 9, 2025

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@gaby
Copy link
Member

gaby commented Apr 9, 2025

@yorickdewid Are you running the container with a tty? docker run -it, or in k8s tty: true.

I run mine with a tty and colors show up

@yorickdewid
Copy link
Author

I have no control over the Kubernetes settings on DigitalOcean's platform, but colors are supported

@gaby
Copy link
Member

gaby commented Apr 9, 2025

@yorickdewid It's a field in your deployment/pod yaml, not in k8s cluster.

Like this:

apiVersion: v1
kind: Pod
metadata:
  name: busybox
spec:
  containers:
  - name: shell
    image: busybox:1.28
    command: ["sleep", "3600"]
    tty: true

@yorickdewid
Copy link
Author

Yeah I get what you're saying but apps are deployed automatically using Heroku tools. This is DigitalOcean's App Platform. There is nothing to configure. The app platform is built on top of Kubernetes, but thats abstracted away from the user. Many cloud providers offer similar services.

@yorickdewid
Copy link
Author

@gaby

@gaby
Copy link
Member

gaby commented Apr 16, 2025

@ReneWerner87 @efectn Thoughts?

@ReneWerner87
Copy link
Member

Such a config option would be ok for me.
Since the consumer knows best when to use the possibilities of colorized log entries.

@gaby
Copy link
Member

gaby commented Apr 16, 2025

@yorickdewid Target branch is main which is Fiber v3. Option should be False by default.

@efectn
Copy link
Member

efectn commented Apr 16, 2025

I am OK with the change, too.

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

No branches or pull requests

4 participants