diff --git a/go.mod b/go.mod index ee87f50..780f370 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/log go 1.17 require ( - github.com/charmbracelet/lipgloss v0.7.1 + github.com/charmbracelet/lipgloss v0.7.2-0.20230801122447-b9dc267bfb97 github.com/go-logfmt/logfmt v0.6.0 github.com/muesli/termenv v0.15.2 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index ea8dfa6..5199403 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E= github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c= +github.com/charmbracelet/lipgloss v0.7.2-0.20230801122447-b9dc267bfb97 h1:RPT8YsyfzoQdtruljiWTpcpx6X0DQQepCN39z/gIXTU= +github.com/charmbracelet/lipgloss v0.7.2-0.20230801122447-b9dc267bfb97/go.mod h1:p4eYUZZJ/0oXTuCQKFF8mqyKCz0ja6y+7DniDDw5KKU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/logger.go b/logger.go index 73805bd..c72decf 100644 --- a/logger.go +++ b/logger.go @@ -282,6 +282,12 @@ func (l *Logger) SetCallerOffset(offset int) { l.callerOffset = offset } +// SetColorProfile force sets the underlying Lip Gloss renderer color profile +// for the TextFormatter. +func (l *Logger) SetColorProfile(profile termenv.Profile) { + l.re.SetColorProfile(profile) +} + // With returns a new logger with the given keyvals added. func (l *Logger) With(keyvals ...interface{}) *Logger { l.mu.Lock() diff --git a/pkg.go b/pkg.go index 2b35b4a..50bcd41 100644 --- a/pkg.go +++ b/pkg.go @@ -8,6 +8,8 @@ import ( "os" "sync" "time" + + "github.com/muesli/termenv" ) var ( @@ -124,6 +126,11 @@ func SetPrefix(prefix string) { defaultLogger.SetPrefix(prefix) } +// SetColorProfile force set the Lip Gloss color profile for the TextFormatter. +func SetColorProfile(profile termenv.Profile) { + defaultLogger.SetColorProfile(profile) +} + // GetPrefix returns the prefix for the default logger. func GetPrefix() string { return defaultLogger.GetPrefix()