From 47ce960d48477e74769e446a6049f5502596e93a Mon Sep 17 00:00:00 2001 From: bashbunni Date: Thu, 10 Oct 2024 15:29:13 -0700 Subject: [PATCH] chore(deps): replace shampoo with colorprofile --- context_test.go | 6 +++--- go.mod | 18 +++++------------- go.sum | 39 ++++++++++----------------------------- json_test.go | 12 ++++++------ logfmt_test.go | 4 ++-- logger.go | 6 +++--- logger_121_test.go | 8 ++++---- logger_test.go | 12 ++++++------ options_test.go | 6 +++--- pkg.go | 2 +- pkg_test.go | 26 +++++++++++++------------- stdlog_test.go | 10 +++++----- text_test.go | 18 +++++++++--------- 13 files changed, 70 insertions(+), 97 deletions(-) diff --git a/context_test.go b/context_test.go index f0aaba0..9f6d958 100644 --- a/context_test.go +++ b/context_test.go @@ -7,7 +7,7 @@ import ( "os" "testing" - "github.com/charmbracelet/shampoo" + "github.com/charmbracelet/colorprofile" "github.com/stretchr/testify/require" ) @@ -16,14 +16,14 @@ func TestLogContext_empty(t *testing.T) { } func TestLogContext_simple(t *testing.T) { - l := New(shampoo.NewWriter(io.Discard, os.Environ())) + l := New(colorprofile.NewWriter(io.Discard, os.Environ())) ctx := WithContext(context.Background(), l) require.Equal(t, l, FromContext(ctx)) } func TestLogContext_fields(t *testing.T) { var buf bytes.Buffer - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) l.SetLevel(DebugLevel) ctx := WithContext(context.Background(), l.With("foo", "bar")) l = FromContext(ctx) diff --git a/go.mod b/go.mod index 72cb25b..30f1ec3 100644 --- a/go.mod +++ b/go.mod @@ -3,29 +3,21 @@ module github.com/charmbracelet/log go 1.19 require ( - github.com/charmbracelet/lipgloss v0.12.2-0.20240722162534-2390dea254e8 - github.com/charmbracelet/shampoo v0.0.0-20240807160433-2fdf07ab2f73 + github.com/charmbracelet/colorprofile v0.1.1 + github.com/charmbracelet/lipgloss v0.13.1-0.20240822211938-b89f1a3db2a4 github.com/go-logfmt/logfmt v0.6.0 github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20231006140011-7918f672742d ) require ( - github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/charmbracelet/x/ansi v0.1.5-0.20240807160011-7b9bd9980386 // indirect - github.com/charmbracelet/x/input v0.1.3 // indirect - github.com/charmbracelet/x/term v0.1.1 // indirect - github.com/charmbracelet/x/windows v0.1.2 // indirect + github.com/charmbracelet/x/ansi v0.3.2 // indirect + github.com/charmbracelet/x/term v0.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect - github.com/muesli/cancelreader v0.2.2 // indirect - github.com/muesli/termenv v0.15.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect - golang.org/x/sys v0.23.0 // indirect + golang.org/x/sys v0.26.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 1caeb67..bac0850 100644 --- a/go.sum +++ b/go.sum @@ -1,36 +1,19 @@ -github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= -github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= -github.com/charmbracelet/lipgloss v0.12.2-0.20240722162534-2390dea254e8 h1:7SMpm8y17K515kM1Q/tiOrSm1jb3hJh94W+LXHWKv+U= -github.com/charmbracelet/lipgloss v0.12.2-0.20240722162534-2390dea254e8/go.mod h1:LCQCsVTQm+lcQLFSiHwSvQUqRXtry1v/2KCfKxdsCeY= -github.com/charmbracelet/shampoo v0.0.0-20240807160433-2fdf07ab2f73 h1:0jbSZZFsjfd8+wAbSX5IX5iTbam8moe81Jt9vpCnxL4= -github.com/charmbracelet/shampoo v0.0.0-20240807160433-2fdf07ab2f73/go.mod h1:McJMdgyoMSHqV0p+ejH4i0jaaK5SAYUp8EgRqUjLBxI= -github.com/charmbracelet/x/ansi v0.1.5-0.20240807160011-7b9bd9980386 h1:aOjzT+GwoykWSR1HiE4nFz+2HD+M7jKa5B3jl6BZhUo= -github.com/charmbracelet/x/ansi v0.1.5-0.20240807160011-7b9bd9980386/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= -github.com/charmbracelet/x/input v0.1.3 h1:oy4TMhyGQsYs/WWJwu1ELUMFnjiUAXwtDf048fHbCkg= -github.com/charmbracelet/x/input v0.1.3/go.mod h1:1gaCOyw1KI9e2j00j/BBZ4ErzRZqa05w0Ghn83yIhKU= -github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI= -github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw= -github.com/charmbracelet/x/windows v0.1.2 h1:Iumiwq2G+BRmgoayww/qfcvof7W/3uLoelhxojXlRWg= -github.com/charmbracelet/x/windows v0.1.2/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ= +github.com/charmbracelet/colorprofile v0.1.1 h1:YsvIsmZ2bazhejG+5g5MPPMpllc7Ks66Nk8l3IvGJ2g= +github.com/charmbracelet/colorprofile v0.1.1/go.mod h1:1htIKZYeI4TQs+OykPvpuBTUbUJxBYeSYBDIZuejMj0= +github.com/charmbracelet/lipgloss v0.13.1-0.20240822211938-b89f1a3db2a4 h1:BuZojjzjQ89wObGNVxJzFqyeh2S6Crbwhybb8bZNveI= +github.com/charmbracelet/lipgloss v0.13.1-0.20240822211938-b89f1a3db2a4/go.mod h1:ZbN5GVH/VrXHPRa1lZqZ1HWJyayJHJYaf9ywsCuI9zQ= +github.com/charmbracelet/x/ansi v0.3.2 h1:wsEwgAN+C9U06l9dCVMX0/L3x7ptvY1qmjMwyfE6USY= +github.com/charmbracelet/x/ansi v0.3.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= +github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= 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= -github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= -github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= -github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= -github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= -github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= @@ -39,10 +22,8 @@ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavM github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= -golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/json_test.go b/json_test.go index 30a98c2..3929fe3 100644 --- a/json_test.go +++ b/json_test.go @@ -9,13 +9,13 @@ import ( "runtime" "testing" - "github.com/charmbracelet/shampoo" + "github.com/charmbracelet/colorprofile" "github.com/stretchr/testify/require" ) func TestJson(t *testing.T) { var buf bytes.Buffer - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) l.SetFormatter(JSONFormatter) cases := []struct { name string @@ -127,7 +127,7 @@ func TestJson(t *testing.T) { func TestJsonCaller(t *testing.T) { var buf bytes.Buffer - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) l.SetFormatter(JSONFormatter) l.SetReportCaller(true) l.SetLevel(DebugLevel) @@ -169,7 +169,7 @@ func TestJsonCaller(t *testing.T) { func TestJsonTime(t *testing.T) { var buf bytes.Buffer - logger := New(shampoo.NewWriter(&buf, os.Environ())) + logger := New(colorprofile.NewWriter(&buf, os.Environ())) logger.SetTimeFunction(_zeroTime) logger.SetFormatter(JSONFormatter) logger.SetReportTimestamp(true) @@ -179,7 +179,7 @@ func TestJsonTime(t *testing.T) { func TestJsonPrefix(t *testing.T) { var buf bytes.Buffer - logger := New(shampoo.NewWriter(&buf, os.Environ())) + logger := New(colorprofile.NewWriter(&buf, os.Environ())) logger.SetFormatter(JSONFormatter) logger.SetPrefix("my-prefix") logger.Info("info") @@ -193,7 +193,7 @@ func TestJsonCustomKey(t *testing.T) { TimestampKey = oldTsKey }() TimestampKey = "other-time" - logger := New(shampoo.NewWriter(&buf, os.Environ())) + logger := New(colorprofile.NewWriter(&buf, os.Environ())) logger.SetTimeFunction(_zeroTime) logger.SetFormatter(JSONFormatter) logger.SetReportTimestamp(true) diff --git a/logfmt_test.go b/logfmt_test.go index 223b399..85e20d5 100644 --- a/logfmt_test.go +++ b/logfmt_test.go @@ -6,13 +6,13 @@ import ( "os" "testing" - "github.com/charmbracelet/shampoo" + "github.com/charmbracelet/colorprofile" "github.com/stretchr/testify/assert" ) func TestLogfmt(t *testing.T) { var buf bytes.Buffer - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) l.SetFormatter(LogfmtFormatter) cases := []struct { name string diff --git a/logger.go b/logger.go index f04f12d..fe62221 100644 --- a/logger.go +++ b/logger.go @@ -134,7 +134,7 @@ func (l *Logger) handle(level Level, ts time.Time, frames []runtime.Frame, msg i if _, err := l.b.WriteTo(l.w); err != nil { if errors.Is(err, io.ErrShortWrite) { // Reset the buffer even if the lengths don't match up. If we're - // using shampoo's Writer, it will strip the ansi sequences based on + // using colorprofile's Writer, it will strip the ansi sequences based on // the color profile which can cause this error. l.b.Reset() } @@ -285,10 +285,10 @@ func (l *Logger) SetOutput(w io.Writer) { // Reuse cached renderers // TODO is this still relevant? // if v, ok := registry.Load(w); ok { - // l.re = v.(*shampoo.Writer) + // l.re = v.(*colorprofile.Writer) // } else { // // TODO calculate background color (termenv.colorcache used to do this) - // l.re = shampoo.NewWriter(w, os.Environ()) + // l.re = colorprofile.NewWriter(w, os.Environ()) // registry.Store(w, l.re) // } } diff --git a/logger_121_test.go b/logger_121_test.go index 7485ec7..04d3f46 100644 --- a/logger_121_test.go +++ b/logger_121_test.go @@ -11,13 +11,13 @@ import ( "testing" "time" - "github.com/charmbracelet/shampoo" + "github.com/charmbracelet/colorprofile" "github.com/stretchr/testify/assert" ) func TestSlogSimple(t *testing.T) { var buf bytes.Buffer - h := New(shampoo.NewWriter(&buf, os.Environ())) + h := New(colorprofile.NewWriter(&buf, os.Environ())) h.SetLevel(DebugLevel) l := slog.New(h) cases := []struct { @@ -75,7 +75,7 @@ func TestSlogSimple(t *testing.T) { func TestSlogWith(t *testing.T) { var buf bytes.Buffer - h := New(shampoo.NewWriter(&buf, os.Environ())) + h := New(colorprofile.NewWriter(&buf, os.Environ())) h.SetLevel(DebugLevel) l := slog.New(h).With("a", "b") cases := []struct { @@ -126,7 +126,7 @@ func TestSlogWith(t *testing.T) { func TestSlogWithGroup(t *testing.T) { var buf bytes.Buffer - h := New(shampoo.NewWriter(&buf, os.Environ())) + h := New(colorprofile.NewWriter(&buf, os.Environ())) l := slog.New(h).WithGroup("charm").WithGroup("bracelet") cases := []struct { name string diff --git a/logger_test.go b/logger_test.go index 9e80aed..ba5b167 100644 --- a/logger_test.go +++ b/logger_test.go @@ -9,13 +9,13 @@ import ( "testing" "time" - "github.com/charmbracelet/shampoo" + "github.com/charmbracelet/colorprofile" "github.com/stretchr/testify/assert" ) func TestSubLogger(t *testing.T) { var buf bytes.Buffer - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) cases := []struct { name string expected string @@ -82,7 +82,7 @@ func TestWrongLevel(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { buf.Reset() - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) l.SetLevel(c.level) l.Info("info") assert.Equal(t, c.expected, buf.String()) @@ -92,7 +92,7 @@ func TestWrongLevel(t *testing.T) { func TestLogFormatter(t *testing.T) { var buf bytes.Buffer - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) l.SetLevel(DebugLevel) cases := []struct { name string @@ -141,7 +141,7 @@ func TestLogFormatter(t *testing.T) { func TestEmptyMessage(t *testing.T) { var buf bytes.Buffer - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) cases := []struct { name string expected string @@ -198,7 +198,7 @@ func TestLogWithPrefix(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { buf.Reset() - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) l.SetPrefix(c.prefix) l.Info(c.msg) assert.Equal(t, c.expected, buf.String()) diff --git a/options_test.go b/options_test.go index 61e34d5..3ef2060 100644 --- a/options_test.go +++ b/options_test.go @@ -7,7 +7,7 @@ import ( "os" "testing" - "github.com/charmbracelet/shampoo" + "github.com/charmbracelet/colorprofile" "github.com/stretchr/testify/require" ) @@ -17,7 +17,7 @@ func TestOptions(t *testing.T) { ReportCaller: true, Fields: []interface{}{"foo", "bar"}, } - logger := NewWithOptions(shampoo.NewWriter(io.Discard, os.Environ()), opts) + logger := NewWithOptions(colorprofile.NewWriter(io.Discard, os.Environ()), opts) require.Equal(t, ErrorLevel, logger.GetLevel()) require.True(t, logger.reportCaller) require.False(t, logger.reportTimestamp) @@ -29,7 +29,7 @@ func TestOptions(t *testing.T) { func TestCallerFormatter(t *testing.T) { var buf bytes.Buffer - l := NewWithOptions(shampoo.NewWriter(&buf, os.Environ()), Options{ReportCaller: true}) + l := NewWithOptions(colorprofile.NewWriter(&buf, os.Environ()), Options{ReportCaller: true}) frames := l.frames(0) frame, _ := frames.Next() file, line, fn := frame.File, frame.Line, frame.Function diff --git a/pkg.go b/pkg.go index 00d9d35..2adde31 100644 --- a/pkg.go +++ b/pkg.go @@ -139,7 +139,7 @@ func SetPrefix(prefix string) { // TODO // SetColorProfile force sets the underlying Lip Gloss renderer color profile // for the TextFormatter. -// func SetColorProfile(profile shampoo.Profile) { +// func SetColorProfile(profile colorprofile.Profile) { // Default().SetColorProfile(profile) // } diff --git a/pkg_test.go b/pkg_test.go index e0faaa9..d5fb99b 100644 --- a/pkg_test.go +++ b/pkg_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/charmbracelet/shampoo" + "github.com/charmbracelet/colorprofile" "github.com/stretchr/testify/assert" ) @@ -34,7 +34,7 @@ func TestDefaultRace(t *testing.T) { func TestGlobal(t *testing.T) { var buf bytes.Buffer - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetTimeFunction(_zeroTime) cases := []struct { name string @@ -76,8 +76,8 @@ func TestGlobal(t *testing.T) { func TestPrint(t *testing.T) { var buf bytes.Buffer - w := shampoo.NewWriter(&buf, os.Environ()) - w.Profile = shampoo.ANSI + w := colorprofile.NewWriter(&buf, os.Environ()) + w.Profile = colorprofile.ANSI SetOutput(w) SetLevel(FatalLevel) SetTimeFunction(_zeroTime) @@ -91,7 +91,7 @@ func TestPrint(t *testing.T) { func TestPrintf(t *testing.T) { var buf bytes.Buffer - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetLevel(FatalLevel) SetTimeFunction(_zeroTime) SetReportTimestamp(true) @@ -138,7 +138,7 @@ func TestFatalf(t *testing.T) { func TestDebugf(t *testing.T) { var buf bytes.Buffer - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetLevel(DebugLevel) SetTimeFunction(_zeroTime) SetReportTimestamp(true) @@ -151,7 +151,7 @@ func TestDebugf(t *testing.T) { func TestInfof(t *testing.T) { var buf bytes.Buffer - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetLevel(InfoLevel) SetReportTimestamp(false) SetReportCaller(false) @@ -162,7 +162,7 @@ func TestInfof(t *testing.T) { func TestWarnf(t *testing.T) { var buf bytes.Buffer - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetLevel(WarnLevel) SetReportCaller(false) SetReportTimestamp(true) @@ -174,7 +174,7 @@ func TestWarnf(t *testing.T) { func TestErrorf(t *testing.T) { var buf bytes.Buffer - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetLevel(ErrorLevel) SetReportCaller(false) SetReportTimestamp(true) @@ -186,7 +186,7 @@ func TestErrorf(t *testing.T) { func TestWith(t *testing.T) { var buf bytes.Buffer - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetLevel(InfoLevel) SetReportCaller(false) SetReportTimestamp(true) @@ -203,7 +203,7 @@ func TestGetLevel(t *testing.T) { func TestPrefix(t *testing.T) { var buf bytes.Buffer - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetLevel(WarnLevel) SetReportCaller(false) SetReportTimestamp(false) @@ -216,7 +216,7 @@ func TestPrefix(t *testing.T) { func TestFormatter(t *testing.T) { var buf bytes.Buffer - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetLevel(InfoLevel) SetReportCaller(false) SetReportTimestamp(false) @@ -233,7 +233,7 @@ func TestWithPrefix(t *testing.T) { func TestGlobalCustomLevel(t *testing.T) { var buf bytes.Buffer lvl := Level(-1) - SetOutput(shampoo.NewWriter(&buf, os.Environ())) + SetOutput(colorprofile.NewWriter(&buf, os.Environ())) SetLevel(lvl) SetReportCaller(false) SetReportTimestamp(false) diff --git a/stdlog_test.go b/stdlog_test.go index 24c2e5c..316c0c8 100644 --- a/stdlog_test.go +++ b/stdlog_test.go @@ -9,14 +9,14 @@ import ( "runtime" "testing" - "github.com/charmbracelet/shampoo" + "github.com/charmbracelet/colorprofile" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestStdLog(t *testing.T) { var buf bytes.Buffer - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) cases := []struct { f func(l *log.Logger) name string @@ -41,7 +41,7 @@ func TestStdLog(t *testing.T) { for _, c := range cases { buf.Reset() t.Run(c.name, func(t *testing.T) { - l.SetOutput(shampoo.NewWriter(&buf, os.Environ())) + l.SetOutput(colorprofile.NewWriter(&buf, os.Environ())) l.SetTimeFunction(_zeroTime) c.f(l.StandardLog()) assert.Equal(t, c.expected, buf.String()) @@ -51,7 +51,7 @@ func TestStdLog(t *testing.T) { func TestStdLog_forceLevel(t *testing.T) { var buf bytes.Buffer - logger := New(shampoo.NewWriter(&buf, os.Environ())) + logger := New(colorprofile.NewWriter(&buf, os.Environ())) cases := []struct { name string expected string @@ -85,7 +85,7 @@ func TestStdLog_forceLevel(t *testing.T) { func TestStdLog_writer(t *testing.T) { var buf bytes.Buffer - logger := New(shampoo.NewWriter(&buf, os.Environ())) + logger := New(colorprofile.NewWriter(&buf, os.Environ())) logger.SetReportCaller(true) _, file, line, ok := runtime.Caller(0) require.True(t, ok) diff --git a/text_test.go b/text_test.go index 32a9658..de5c4b9 100644 --- a/text_test.go +++ b/text_test.go @@ -13,7 +13,7 @@ import ( "time" "github.com/charmbracelet/lipgloss" - "github.com/charmbracelet/shampoo" + "github.com/charmbracelet/colorprofile" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -24,14 +24,14 @@ func _zeroTime(time.Time) time.Time { func TestNilStyles(t *testing.T) { st := DefaultStyles() - l := New(shampoo.NewWriter(io.Discard, os.Environ())) + l := New(colorprofile.NewWriter(io.Discard, os.Environ())) l.SetStyles(nil) assert.Equal(t, st, l.styles) } func TestTextCaller(t *testing.T) { var buf bytes.Buffer - logger := New(shampoo.NewWriter(&buf, os.Environ())) + logger := New(colorprofile.NewWriter(&buf, os.Environ())) logger.SetReportCaller(true) // We calculate the caller offset based on the caller line number. _, file, line, _ := runtime.Caller(0) @@ -100,7 +100,7 @@ func TestTextCaller(t *testing.T) { func TestTextLogger(t *testing.T) { var buf bytes.Buffer - logger := New(shampoo.NewWriter(&buf, os.Environ())) + logger := New(colorprofile.NewWriter(&buf, os.Environ())) cases := []struct { name string expected string @@ -211,7 +211,7 @@ func TestTextLogger(t *testing.T) { func TestTextHelper(t *testing.T) { var buf bytes.Buffer - logger := New(shampoo.NewWriter(&buf, os.Environ())) + logger := New(colorprofile.NewWriter(&buf, os.Environ())) logger.SetReportCaller(true) helper := func() { logger.Helper() @@ -226,7 +226,7 @@ func TestTextHelper(t *testing.T) { func TestTextFatal(t *testing.T) { var buf bytes.Buffer - logger := New(shampoo.NewWriter(&buf, os.Environ())) + logger := New(colorprofile.NewWriter(&buf, os.Environ())) logger.SetReportCaller(true) if os.Getenv("FATAL") == "1" { logger.Fatal("i'm dead") @@ -244,8 +244,8 @@ func TestTextFatal(t *testing.T) { func TestTextValueStyles(t *testing.T) { var buf bytes.Buffer - w := shampoo.NewWriter(&buf, os.Environ()) - w.Profile = shampoo.ANSI256 + w := colorprofile.NewWriter(&buf, os.Environ()) + w.Profile = colorprofile.ANSI256 logger := New(w) st := DefaultStyles() st.Value = lipgloss.NewStyle().Bold(true) @@ -411,7 +411,7 @@ func TestTextValueStyles(t *testing.T) { func TestCustomLevelStyle(t *testing.T) { var buf bytes.Buffer - l := New(shampoo.NewWriter(&buf, os.Environ())) + l := New(colorprofile.NewWriter(&buf, os.Environ())) st := DefaultStyles() lvl := Level(1234) st.Levels[lvl] = lipgloss.NewStyle().Bold(true).SetString("FUNKY")