-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1e7d89
commit d7ca56a
Showing
9 changed files
with
89 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
module examples | ||
|
||
go 1.17 | ||
go 1.18 | ||
|
||
replace github.com/charmbracelet/log => ../ | ||
|
||
require ( | ||
github.com/charmbracelet/lipgloss v0.10.0 | ||
github.com/charmbracelet/lipgloss v0.11.1-0.20240716175531-e78ed6376350 | ||
github.com/charmbracelet/log v0.0.0-00010101000000-000000000000 | ||
) | ||
|
||
require ( | ||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect | ||
github.com/charmbracelet/x/ansi v0.1.4 // indirect | ||
github.com/charmbracelet/x/input v0.1.0 // indirect | ||
github.com/charmbracelet/x/term v0.1.1 // indirect | ||
github.com/charmbracelet/x/windows v0.1.0 // indirect | ||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect | ||
github.com/go-logfmt/logfmt v0.6.0 // indirect | ||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect | ||
github.com/mattn/go-isatty v0.0.18 // indirect | ||
github.com/mattn/go-runewidth v0.0.15 // indirect | ||
github.com/muesli/reflow v0.3.0 // indirect | ||
github.com/muesli/termenv v0.15.2 // indirect | ||
github.com/muesli/cancelreader v0.2.2 // indirect | ||
github.com/rivo/uniseg v0.4.7 // indirect | ||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect | ||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
golang.org/x/sys v0.20.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ import ( | |
"time" | ||
|
||
"github.com/charmbracelet/lipgloss" | ||
Check failure on line 14 in logger.go GitHub Actions / coverage / coverage
Check failure on line 14 in logger.go GitHub Actions / build (stable) / govulncheck
|
||
"github.com/muesli/termenv" | ||
) | ||
|
||
// ErrMissingValue is returned when a key is missing a value. | ||
|
@@ -23,10 +22,9 @@ type LoggerOption = func(*Logger) | |
|
||
// Logger is a Logger that implements Logger. | ||
type Logger struct { | ||
w io.Writer | ||
w *lipgloss.Writer | ||
b bytes.Buffer | ||
mu *sync.RWMutex | ||
re *lipgloss.Renderer | ||
|
||
isDiscard uint32 | ||
|
||
|
@@ -272,19 +270,12 @@ func (l *Logger) SetOutput(w io.Writer) { | |
if w == nil { | ||
w = os.Stderr | ||
} | ||
l.w = w | ||
l.w = lipgloss.NewWriter(w, nil) | ||
var isDiscard uint32 | ||
if w == io.Discard { | ||
isDiscard = 1 | ||
} | ||
atomic.StoreUint32(&l.isDiscard, isDiscard) | ||
// Reuse cached renderers | ||
if v, ok := registry.Load(w); ok { | ||
l.re = v.(*lipgloss.Renderer) | ||
} else { | ||
l.re = lipgloss.NewRenderer(w, termenv.WithColorCache(true)) | ||
registry.Store(w, l.re) | ||
} | ||
} | ||
|
||
// SetFormatter sets the formatter. | ||
|
@@ -310,8 +301,8 @@ func (l *Logger) SetCallerOffset(offset int) { | |
|
||
// SetColorProfile force sets the underlying Lip Gloss renderer color profile | ||
// for the TextFormatter. | ||
func (l *Logger) SetColorProfile(profile termenv.Profile) { | ||
l.re.SetColorProfile(profile) | ||
func (l *Logger) SetColorProfile(profile lipgloss.Profile) { | ||
l.w.Profile = profile | ||
} | ||
|
||
// SetStyles sets the logger styles for the TextFormatter. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.