diff --git a/.github/.goreleaser.yml b/.github/.goreleaser.yml deleted file mode 100644 index 18d3219..0000000 --- a/.github/.goreleaser.yml +++ /dev/null @@ -1,13 +0,0 @@ -release: - github: - owner: lmittmann - name: tint - draft: true - footer: | - **Full Changelog**: [`{{ .PreviousTag }}…{{ .Tag }}`](https://github.com/{{ .Env.GITHUB_REPOSITORY }}/compare/{{ .PreviousTag }}...{{ .Tag }}) - -changelog: - sort: asc - -builds: -- skip: true diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9b921fa..d34e75a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,33 +1,39 @@ name: Go on: - - push - - pull_request + push: + branches: + - main + pull_request: jobs: - fmt_vet: - name: Fmt & Vet + lint: + name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: "1.21" - name: go fmt run: | - gofmt -s -d . > fmt.out - cat fmt.out - test -z $(cat fmt.out) + output=$(gofmt -s -d .) + echo "$output" + test -z "$output" - name: go vet run: go vet ./... + - name: install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + - name: staticcheck + run: staticcheck ./... test: name: Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: "1.21" - name: go test run: TZ="" go test ./... -tags=faketime diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ebbf9f5..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Release - -on: - push: - tags: - - v* - -permissions: - contents: write - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: goreleaser/goreleaser-action@v4 - with: - version: latest - args: release --config .github/.goreleaser.yml - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/handler.go b/handler.go index 62d153c..d54b5d7 100644 --- a/handler.go +++ b/handler.go @@ -345,7 +345,7 @@ func (h *handler) appendAttr(buf *buffer, attr slog.Attr, groupsPrefix string, g } } else if err, ok := attr.Value.Any().(tintError); ok { // append tintError - h.appendTintError(buf, err, groupsPrefix) + h.appendTintError(buf, err, attr.Key, groupsPrefix) buf.WriteByte(' ') } else { h.appendKey(buf, attr.Key, groupsPrefix) @@ -395,9 +395,9 @@ func (h *handler) appendValue(buf *buffer, v slog.Value, quote bool) { } } -func (h *handler) appendTintError(buf *buffer, err error, groupsPrefix string) { +func (h *handler) appendTintError(buf *buffer, err error, attrKey, groupsPrefix string) { buf.WriteStringIf(!h.noColor, ansiBrightRedFaint) - appendString(buf, groupsPrefix+errKey, true) + appendString(buf, groupsPrefix+attrKey, true) buf.WriteByte('=') buf.WriteStringIf(!h.noColor, ansiResetFaint) appendString(buf, err.Error(), true) diff --git a/handler_test.go b/handler_test.go index 8e710fd..737f2d0 100644 --- a/handler_test.go +++ b/handler_test.go @@ -344,6 +344,14 @@ func TestHandler(t *testing.T) { }, Want: `Nov 10 23:00:00.000 INF test key="{A:123 B:}"`, }, + { // https://github.com/lmittmann/tint/pull/66 + F: func(l *slog.Logger) { + errAttr := tint.Err(errors.New("fail")) + errAttr.Key = "error" + l.Error("test", errAttr) + }, + Want: `Nov 10 23:00:00.000 ERR test error=fail`, + }, } for i, test := range tests {