From f954dc8f8b7968e92d184db10a943e5d62e99105 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Wed, 11 Sep 2024 11:18:34 -0500 Subject: [PATCH 1/5] change type of Level to int (#141) * change type of Level to int Signed-off-by: Jason Hall * support <1.21 Signed-off-by: Jason Hall --------- Signed-off-by: Jason Hall --- level.go | 4 ++-- logger.go | 6 +++--- logger_121.go | 2 +- logger_no121.go | 2 +- pkg.go | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/level.go b/level.go index cba2297..1c2ce8e 100644 --- a/level.go +++ b/level.go @@ -8,7 +8,7 @@ import ( ) // Level is a logging level. -type Level int32 +type Level int const ( // DebugLevel is the debug level. @@ -22,7 +22,7 @@ const ( // FatalLevel is the fatal level. FatalLevel Level = 12 // noLevel is used with log.Print. - noLevel Level = math.MaxInt32 + noLevel Level = math.MaxInt ) // String returns the string representation of the level. diff --git a/logger.go b/logger.go index f4120c1..ece9349 100644 --- a/logger.go +++ b/logger.go @@ -30,7 +30,7 @@ type Logger struct { isDiscard uint32 - level int32 + level int64 prefix string timeFunc TimeFunction timeFormat string @@ -59,7 +59,7 @@ func (l *Logger) Log(level Level, msg interface{}, keyvals ...interface{}) { } // check if the level is allowed - if atomic.LoadInt32(&l.level) > int32(level) { + if atomic.LoadInt64(&l.level) > int64(level) { return } @@ -234,7 +234,7 @@ func (l *Logger) GetLevel() Level { func (l *Logger) SetLevel(level Level) { l.mu.Lock() defer l.mu.Unlock() - atomic.StoreInt32(&l.level, int32(level)) + atomic.StoreInt64(&l.level, int64(level)) } // GetPrefix returns the current prefix. diff --git a/logger_121.go b/logger_121.go index 73bee9c..b5cf956 100644 --- a/logger_121.go +++ b/logger_121.go @@ -23,7 +23,7 @@ const slogKindGroup = slog.KindGroup // // Implements slog.Handler. func (l *Logger) Enabled(_ context.Context, level slog.Level) bool { - return atomic.LoadInt32(&l.level) <= int32(level) + return atomic.LoadInt64(&l.level) <= int64(level) } // Handle handles the Record. It will only be called if Enabled returns true. diff --git a/logger_no121.go b/logger_no121.go index bf28cf4..ce8b8a2 100644 --- a/logger_no121.go +++ b/logger_no121.go @@ -24,7 +24,7 @@ const slogKindGroup = slog.KindGroup // // Implements slog.Handler. func (l *Logger) Enabled(_ context.Context, level slog.Level) bool { - return atomic.LoadInt32(&l.level) <= int32(level) + return atomic.LoadInt64(&l.level) <= int64(level) } // Handle handles the Record. It will only be called if Enabled returns true. diff --git a/pkg.go b/pkg.go index 9e083a3..712bb38 100644 --- a/pkg.go +++ b/pkg.go @@ -52,7 +52,7 @@ func NewWithOptions(w io.Writer, o Options) *Logger { b: bytes.Buffer{}, mu: &sync.RWMutex{}, helpers: &sync.Map{}, - level: int32(o.Level), + level: int64(o.Level), reportTimestamp: o.ReportTimestamp, reportCaller: o.ReportCaller, prefix: o.Prefix, From 624268e1b7ae6b5e412839f62ff6677a85e97baa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:52:22 +0000 Subject: [PATCH 2/5] feat(deps): bump github.com/charmbracelet/lipgloss from 0.12.1 to 0.13.0 (#140) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1c92323..90e1023 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/log go 1.19 require ( - github.com/charmbracelet/lipgloss v0.12.1 + github.com/charmbracelet/lipgloss v0.13.0 github.com/go-logfmt/logfmt v0.6.0 github.com/muesli/termenv v0.15.2 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index 2222caf..cd19463 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ 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.1 h1:/gmzszl+pedQpjCOH+wFkZr/N90Snz40J/NR7A0zQcs= -github.com/charmbracelet/lipgloss v0.12.1/go.mod h1:V2CiwIuhx9S1S1ZlADfOj9HmxeMAORuz5izHb0zGbB8= +github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= +github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/x/ansi v0.1.4 h1:IEU3D6+dWwPSgZ6HBH+v6oUuZ/nVawMiWj5831KfiLM= github.com/charmbracelet/x/ansi v0.1.4/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From dc6766fc119e829ced14339a753abe910725afee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:12:08 -0400 Subject: [PATCH 3/5] feat(deps): bump github.com/charmbracelet/lipgloss from 0.13.0 to 0.13.1 (#146) Bumps [github.com/charmbracelet/lipgloss](https://github.com/charmbracelet/lipgloss) from 0.13.0 to 0.13.1. - [Release notes](https://github.com/charmbracelet/lipgloss/releases) - [Changelog](https://github.com/charmbracelet/lipgloss/blob/master/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/lipgloss/compare/v0.13.0...v0.13.1) --- updated-dependencies: - dependency-name: github.com/charmbracelet/lipgloss dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 90e1023..23b148f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/log go 1.19 require ( - github.com/charmbracelet/lipgloss v0.13.0 + github.com/charmbracelet/lipgloss v0.13.1 github.com/go-logfmt/logfmt v0.6.0 github.com/muesli/termenv v0.15.2 github.com/stretchr/testify v1.9.0 @@ -12,7 +12,7 @@ require ( require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/charmbracelet/x/ansi v0.1.4 // indirect + github.com/charmbracelet/x/ansi v0.3.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect diff --git a/go.sum b/go.sum index cd19463..d2fb1db 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,9 @@ 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.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= -github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= -github.com/charmbracelet/x/ansi v0.1.4 h1:IEU3D6+dWwPSgZ6HBH+v6oUuZ/nVawMiWj5831KfiLM= -github.com/charmbracelet/x/ansi v0.1.4/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/lipgloss v0.13.1 h1:Oik/oqDTMVA01GetT4JdEC033dNzWoQHdWnHnQmXE2A= +github.com/charmbracelet/lipgloss v0.13.1/go.mod h1:zaYVJ2xKSKEnTEEbX6uAHabh2d975RJ+0yfkFpRBz5U= +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/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/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= From cca527fa4e341edf51d3063a84a4cd781d8bfa8a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 19:04:24 +0000 Subject: [PATCH 4/5] feat(deps): bump github.com/charmbracelet/lipgloss from 0.13.1 to 1.0.0 (#148) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 23b148f..11db01e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/log go 1.19 require ( - github.com/charmbracelet/lipgloss v0.13.1 + github.com/charmbracelet/lipgloss v1.0.0 github.com/go-logfmt/logfmt v0.6.0 github.com/muesli/termenv v0.15.2 github.com/stretchr/testify v1.9.0 @@ -12,7 +12,7 @@ require ( require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/charmbracelet/x/ansi v0.3.2 // indirect + github.com/charmbracelet/x/ansi v0.4.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect diff --git a/go.sum b/go.sum index d2fb1db..a0396d4 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,9 @@ 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.13.1 h1:Oik/oqDTMVA01GetT4JdEC033dNzWoQHdWnHnQmXE2A= -github.com/charmbracelet/lipgloss v0.13.1/go.mod h1:zaYVJ2xKSKEnTEEbX6uAHabh2d975RJ+0yfkFpRBz5U= -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/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= +github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= +github.com/charmbracelet/x/ansi v0.4.2 h1:0JM6Aj/g/KC154/gOP4vfxun0ff6itogDYk41kof+qk= +github.com/charmbracelet/x/ansi v0.4.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= 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/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= From d3e462e0699859de00fc1bd43c8c5251cfd60a29 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Fri, 1 Nov 2024 13:09:25 -0400 Subject: [PATCH 5/5] feat(ci): update linter config and add sync job --- .github/workflows/lint-sync.yml | 14 ++++++++++++ .github/workflows/lint.yml | 15 ++----------- .golangci-soft.yml | 40 +++++++++++++++++++++++++++++++++ .golangci.yml | 11 ++------- 4 files changed, 58 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/lint-sync.yml create mode 100644 .golangci-soft.yml diff --git a/.github/workflows/lint-sync.yml b/.github/workflows/lint-sync.yml new file mode 100644 index 0000000..ecf8580 --- /dev/null +++ b/.github/workflows/lint-sync.yml @@ -0,0 +1,14 @@ +name: lint-sync +on: + schedule: + # every Sunday at midnight + - cron: "0 0 * * 0" + workflow_dispatch: # allows manual triggering + +permissions: + contents: write + pull-requests: write + +jobs: + lint: + uses: charmbracelet/meta/.github/workflows/lint-sync.yml@main diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 966a6e4..a1d6d0e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,16 +4,5 @@ on: pull_request: jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: ^1 - - name: golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - # Optional: golangci-lint command line arguments. - args: --issues-exit-code=1 + lint: + uses: charmbracelet/meta/.github/workflows/lint.yml@main diff --git a/.golangci-soft.yml b/.golangci-soft.yml new file mode 100644 index 0000000..d325d4f --- /dev/null +++ b/.golangci-soft.yml @@ -0,0 +1,40 @@ +run: + tests: false + issues-exit-code: 0 + +issues: + include: + - EXC0001 + - EXC0005 + - EXC0011 + - EXC0012 + - EXC0013 + + max-issues-per-linter: 0 + max-same-issues: 0 + +linters: + enable: + - exhaustive + - goconst + - godot + - godox + - mnd + - gomoddirectives + - goprintffuncname + - misspell + - nakedret + - nestif + - noctx + - nolintlint + - prealloc + - wrapcheck + + # disable default linters, they are already enabled in .golangci.yml + disable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused diff --git a/.golangci.yml b/.golangci.yml index d786f65..d6789e0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,21 +15,14 @@ issues: linters: enable: - bodyclose - - dupl - - exportloopref - - goconst - - godot - - godox - gofumpt - goimports - - goprintffuncname - gosec - - misspell - - nolintlint - - prealloc + - nilerr - revive - rowserrcheck - sqlclosecheck + - tparallel - unconvert - unparam - whitespace