From c4b42929a2f81f8fc100808a5e28956f33fe2739 Mon Sep 17 00:00:00 2001 From: lmittmann Date: Thu, 18 Jan 2024 23:15:31 +0100 Subject: [PATCH 1/3] dropped goreleaser --- .github/.goreleaser.yml | 13 ------------- .github/workflows/release.yml | 23 ----------------------- 2 files changed, 36 deletions(-) delete mode 100644 .github/.goreleaser.yml delete mode 100644 .github/workflows/release.yml 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/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 }} From 069f95f67402ac75dbf48ed5d01d3de2242011f5 Mon Sep 17 00:00:00 2001 From: lmittmann Date: Sun, 16 Jun 2024 11:50:52 +0200 Subject: [PATCH 2/3] updated CI --- .github/workflows/go.yml | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) 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 From 368de753ea2a714981dac3bed7390460b9ae4a93 Mon Sep 17 00:00:00 2001 From: Aleksandr Kliuev Date: Wed, 10 Jul 2024 18:04:40 +0200 Subject: [PATCH 3/3] Preserve `tint.Err` attribute key (#66) * Preserve the 'err' Attribute Name We do not always have control over how attribute names are defined. However, it is beneficial to highlight errors in development logs for better visibility. * make testcase consistent with the test suite --------- Co-authored-by: lmittmann --- handler.go | 6 +++--- handler_test.go | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) 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 {