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

No colors issue Persists With Io.MultiWriter. #80

Closed
M1ndo opened this issue Oct 24, 2023 · 3 comments
Closed

No colors issue Persists With Io.MultiWriter. #80

M1ndo opened this issue Oct 24, 2023 · 3 comments

Comments

@M1ndo
Copy link

M1ndo commented Oct 24, 2023

#69 Didn't fix the issue not in my case. I can't seem to get colors working unless setting color file to termenv.TrueColor.
Os: Arch Linux

package main

import (
	"github.com/charmbracelet/log"
	"io"
	"os"
	"time"
	// "github.com/muesli/termenv"
)

func main() {
	file := "logger.log"
	LogFile, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
	if err != nil {
		panic(err)
	}
	writers := []io.Writer{}
	writers = append(writers, os.Stderr)
	writers = append(writers, LogFile)
	writer := io.MultiWriter(writers...)
	// OR io.MultiWriter(LogFile, os.Stdout)

	Options := log.Options{
		TimeFunction:    time.Now,
		TimeFormat:      time.DateTime,
		ReportTimestamp: true,
		Level:           log.InfoLevel,
		Prefix:          "Logging 👾 ",
	}

	logger := log.NewWithOptions(writer, Options)
	// logger.SetColorProfile(termenv.TrueColor) // Works
	logger.Info("this is a test")
}
@dezren39
Copy link
Contributor

dezren39 commented Nov 6, 2023

#84 solved a related issue i had, you may want to give it another swing using latest main branch and you may see that it works nwo.

@M1ndo
Copy link
Author

M1ndo commented Nov 7, 2023

@dezren39 Thanks for the info, it sure did fix it

@M1ndo M1ndo closed this as completed Nov 7, 2023
@hayyaun
Copy link

hayyaun commented Feb 2, 2024

#84 solved a related issue i had, you may want to give it another swing using latest main branch and you may see that it works nwo.

How did you manage to fix it? can you give more details please.

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

3 participants