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

Allow the user to force color output on non-tty devices #63

Closed
wants to merge 1 commit into from

Conversation

mgale
Copy link

@mgale mgale commented Jul 6, 2023

I used this workflow when using io.Pipe, allowing me to redirect the logging output to a viewport.

@bashbunni
Copy link
Member

Hey @mgale do you mind providing an example of how you used the changes in this PR so we can test? Thank you!

@mgale
Copy link
Author

mgale commented Jul 17, 2023

Hey @mgale do you mind providing an example of how you used the changes in this PR so we can test? Thank you!

Hello @bashbunni sorry for this drive by PR, also I should have added tests.

I tried adding tests on my own but things only work correctly when I execute the tests from the command line using go test. If I try executing the tests via vscode the colour output is always disabled.

How I am using this functionality...

  1. In my CLI app I have a viewport where I want to stream events as things are happening (making API calls, etc)
  2. I wanted to use the log format / output as it is setup already with timestamps and colours.

I created an events file:

f, err := os.OpenFile(ltEventLog, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
...
eventLogger := log.NewWithOptions(f, log.Options{ReportTimestamp: true, ForceColors: true})
eventLogger.Info(...)

Then I have a separate go routine that is using tail.TailFile, reads lines from the file and updates the view by doing a p.Send() method on a tea.Program.

aymanbagabas added a commit that referenced this pull request Aug 1, 2023
Add `SetColorProfile` to force change the Lip Gloss renderer color profile.

Needs: charmbracelet/lipgloss#212
Fixes: #63
aymanbagabas added a commit that referenced this pull request Aug 1, 2023
Add `SetColorProfile` to force change the Lip Gloss renderer color profile.

Needs: charmbracelet/lipgloss#212
Fixes: #63
@aymanbagabas
Copy link
Member

Hi @mgale, could you try this PR? It takes a simpler approach to force the color output #69

@mgale
Copy link
Author

mgale commented Aug 4, 2023

Hi @mgale, could you try this PR? It takes a simpler approach to force the color output #69

Hello, FYI I am on vacation for the month of August however I managed to give this a quick test and it worked for me. Thank you.

aymanbagabas added a commit that referenced this pull request Aug 22, 2023
Add `SetColorProfile` to force change the Lip Gloss renderer color profile.

Needs: charmbracelet/lipgloss#212
Fixes: #63
@mgale
Copy link
Author

mgale commented Aug 30, 2023

Closing PR in favor of: #69

@mgale mgale closed this Aug 30, 2023
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

Successfully merging this pull request may close these issues.

3 participants