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

Colour output on different terminals #20

Closed
alexslade opened this issue Jul 6, 2023 · 3 comments
Closed

Colour output on different terminals #20

alexslade opened this issue Jul 6, 2023 · 3 comments

Comments

@alexslade
Copy link

Weird one here... I'm slightly abusing Owl to render an interface for a MUD that is displayed over a LiveView, and I'm hitting a funny issue when deploying.

The ansi colour codes work fine on dev, when I'm usind a LiveScreen and updating a block, I observe its io_request message and the colour codes are present.

But when I do this in prod (Debian / Fly.io), the same messages contain no colour codes. I'm observing the raw data in logs:

dev

�[2K�[33Hello�[39m world

prod

�[2KHello world

(No colour codes)

Any pointers for what might be happening? I've been trying to debug this morning and my best guess is that Owl is doing some kind of terminal support check and disabling colours...

@fuelen
Copy link
Owner

fuelen commented Jul 6, 2023

Owl doesn't disable colours, Elixir does this by itself. Owl uses IO.ANSI.format/2:

|> IO.ANSI.format()

which uses IO.ANSI.enabled?/0 by default. Looks like IO.ANSI.enabled/0 returns false in prod.
You can enable it manually
Application.put_env(:elixir, :ansi_enabled, true)

but this keep in mind that this change is global

@fuelen
Copy link
Owner

fuelen commented Jul 6, 2023

I think we can add an optional second parameter to Owl.Data.to_ansidata/1 so it behaves similarly to IO.ANSI.format/2 and you'd be able to force ANSI formatting even though it is disabled globally. Will it solve your issue?

@alexslade
Copy link
Author

Thanks for the pointer, that's exactly the cause :)

I have no problem enabling ansi colours for this app, so that works for now. Happy to close this issue if you are.

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

No branches or pull requests

2 participants