Skip to content

Commit

Permalink
chore: merge branch 'main' into v2-exp
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Nov 1, 2024
2 parents a697bd2 + d3e462e commit e66b83d
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 50 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/lint-sync.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 2 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 40 additions & 0 deletions .golangci-soft.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 2 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ go 1.19

require (
github.com/charmbracelet/colorprofile v0.1.2
github.com/charmbracelet/lipgloss v0.13.2-0.20241023173701-23b08d1d3588
github.com/charmbracelet/lipgloss v1.0.0
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/charmbracelet/x/ansi v0.3.2 // indirect
github.com/charmbracelet/x/input v0.2.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/x/ansi v0.4.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/muesli/cancelreader v0.2.2 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // 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
Expand Down
29 changes: 14 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
github.com/charmbracelet/colorprofile v0.1.1 h1:YsvIsmZ2bazhejG+5g5MPPMpllc7Ks66Nk8l3IvGJ2g=
github.com/charmbracelet/colorprofile v0.1.1/go.mod h1:1htIKZYeI4TQs+OykPvpuBTUbUJxBYeSYBDIZuejMj0=
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/colorprofile v0.1.2 h1:nuB1bd/yAExT4fkcZvpqtQ2N5/8cJHSRIKb6CzT7lAM=
github.com/charmbracelet/colorprofile v0.1.2/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/lipgloss v0.13.2-0.20241023173701-23b08d1d3588 h1:P0eMGSpqhHhVEN9HRD9Dl0ZaXIJWHINkW4DjPC/0EIQ=
github.com/charmbracelet/lipgloss v0.13.2-0.20241023173701-23b08d1d3588/go.mod h1:S+zi6HCChYq08TKQZpf3KEi7D/RO62JjxwNXbv6KVxA=
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/input v0.2.0 h1:1Sv+y/flcqUfUH2PXNIDKDIdT2G8smOnGOgawqhwy8A=
github.com/charmbracelet/x/input v0.2.0/go.mod h1:KUSFIS6uQymtnr5lHVSOK9j8RvwTD4YHnWnzJUYnd/M=
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/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/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
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.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
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=
Expand All @@ -32,7 +31,7 @@ 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.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=
Expand Down
4 changes: 2 additions & 2 deletions level.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// Level is a logging level.
type Level int32
type Level int

const (
// DebugLevel is the debug level.
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Logger struct {

isDiscard uint32

level int32
level int64
prefix string
timeFunc TimeFunction
timeFormat string
Expand Down Expand Up @@ -56,7 +56,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
}

Expand Down Expand Up @@ -238,7 +238,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.
Expand Down
2 changes: 1 addition & 1 deletion logger_121.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion logger_no121.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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,
Expand Down

0 comments on commit e66b83d

Please sign in to comment.