Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: update to go 1.21.0, add log/slog support #72

Merged
merged 7 commits into from
Aug 12, 2024

Conversation

ttys3
Copy link
Collaborator

@ttys3 ttys3 commented Aug 10, 2023

go 1.21.0 stdlib slog provides structured logging, in which log records include a message, a severity level, and various other attributes expressed as key-value pairs.

see https://pkg.go.dev/log/slog

@codecov
Copy link

codecov bot commented Aug 10, 2023

Codecov Report

Merging #72 (ea06f45) into master (d6826ff) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
+ Coverage   98.79%   98.80%   +0.01%     
==========================================
  Files          12       14       +2     
  Lines         581      588       +7     
==========================================
+ Hits          574      581       +7     
  Misses          5        5              
  Partials        2        2              
Files Changed Coverage Δ
staticrules.go 100.00% <ø> (ø)
internal/checkers/filter.go 100.00% <100.00%> (ø)
internal/checkers/slog.go 100.00% <100.00%> (ø)
internal/checkers/zap.go 100.00% <100.00%> (ø)
loggercheck.go 94.35% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ttys3 ttys3 requested a review from timonwong August 10, 2023 10:08
@ttys3 ttys3 marked this pull request as draft August 10, 2023 12:45
@ttys3
Copy link
Collaborator Author

ttys3 commented Aug 10, 2023

Oops, I found things missing ...

it has something like Zap:

// Group returns an Attr for a Group Value.
// The first argument is the key; the remaining arguments
// are converted to Attrs as in [Logger.Log].
//
// Use Group to collect several key-value pairs under a single
// key on a log line, or as the result of LogValue
// in order to log a single value as multiple Attrs.
func Group(key string, args ...any) Attr {
	return Attr{key, GroupValue(argsToAttrSlice(args)...)}
}

@ttys3 ttys3 marked this pull request as ready for review August 10, 2023 13:01
@ttys3
Copy link
Collaborator Author

ttys3 commented Aug 10, 2023

OK. fixed

@timonwong timonwong enabled auto-merge (squash) August 25, 2023 13:55
.github/workflows/ci.yml Show resolved Hide resolved
testdata/src/a/all/example.go Show resolved Hide resolved
@phith0n
Copy link

phith0n commented Aug 10, 2024

Hi, a year has passed; when will support for slog be available?

@timonwong
Copy link
Owner

@phith0n I think sloglint is a dedicated better solution for slog (it's included in golangcilint now)

@phith0n
Copy link

phith0n commented Aug 12, 2024

@phith0n I think sloglint is a dedicated better solution for slog (it's included in golangcilint now)

Noted, thanks!

@ttys3
Copy link
Collaborator Author

ttys3 commented Aug 12, 2024

@phith0n I think sloglint is a dedicated better solution for slog (it's included in golangcilint now)

it may suitable for std slog

but not works for slog based wrappers. this is where loggercheck works better

@ttys3
Copy link
Collaborator Author

ttys3 commented Aug 12, 2024

since go 1.20 has been eof (https://endoflife.date/go)

Is it still necessary for us to continue supporting Go 1.20?

@timonwong timonwong merged commit 4359606 into timonwong:master Aug 12, 2024
@timonwong
Copy link
Owner

@ttys3 promising, thanks for not giving up 😂

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants