Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: add slog logging #432

Merged
merged 8 commits into from
Aug 29, 2023
Merged

feat: add slog logging #432

merged 8 commits into from
Aug 29, 2023

Conversation

muhlemmer
Copy link
Collaborator

@muhlemmer muhlemmer commented Aug 24, 2023

This change adds logging to oidc, using /x/exp/slog.

In the OP logging is mostly done in the AuthRequestError and RequestError functions. Request based logging can also be enable with zitadel/logging's Middleware. The example OP is adjust to show this behavior.

The RP also gets the ability to log. Either from a context logger, or a fallback set directly on the RP.

slog is the new structured logging library which is already part of the standard library from go 1.21 in the log/slog package. As we support the last two major version of go, we must start by using the experimental version. Bevavior and API are mostly the same. After the release of Go 1.22, we can drop support for 1.20 and change all the imports to log/slog.

Depends on zitadel/logging#18 and subsequent release tagging.

Closes #379

integrate with golang.org/x/exp/slog for logging.
provide a middleware for request scoped logging.

BREAKING CHANGES:

1. OpenIDProvider and sub-interfaces get a Logger()
method to return the configured logger;
2. AuthRequestError now takes the complete Authorizer,
instead of only the encoder. So that it may use its Logger() method.
3. RequestError now takes a Logger as argument.
without middleware for now
@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

Merging #432 (c58b7b6) into next (6708ef4) will increase coverage by 0.81%.
The diff coverage is 65.94%.

@@            Coverage Diff             @@
##             next     #432      +/-   ##
==========================================
+ Coverage   53.34%   54.15%   +0.81%     
==========================================
  Files          74       75       +1     
  Lines        5635     5724      +89     
==========================================
+ Hits         3006     3100      +94     
+ Misses       2376     2369       -7     
- Partials      253      255       +2     
Files Changed Coverage Δ
pkg/client/client.go 22.27% <0.00%> (-0.36%) ⬇️
pkg/client/rp/device.go 0.00% <0.00%> (ø)
pkg/op/session.go 32.91% <0.00%> (ø)
pkg/op/token_client_credentials.go 42.25% <0.00%> (ø)
pkg/op/auth_request.go 57.89% <6.25%> (+0.75%) ⬆️
pkg/op/token_code.go 36.14% <25.00%> (ø)
pkg/op/token_jwt_profile.go 16.66% <25.00%> (ø)
pkg/op/token_exchange.go 51.73% <33.33%> (ø)
pkg/op/token_refresh.go 39.56% <33.33%> (ø)
pkg/client/rp/relying_party.go 55.94% <50.00%> (-0.43%) ⬇️
... and 9 more

@muhlemmer muhlemmer marked this pull request as ready for review August 28, 2023 09:08
@muhlemmer muhlemmer linked an issue Aug 28, 2023 that may be closed by this pull request
4 tasks
@muhlemmer muhlemmer added this to the v3 milestone Aug 28, 2023
@muhlemmer muhlemmer requested a review from livio-a August 28, 2023 10:51
@livio-a livio-a merged commit 0879c88 into next Aug 29, 2023
8 checks passed
@livio-a livio-a deleted the feat-logging/slog branch August 29, 2023 12:07
@github-actions
Copy link

🎉 This PR is included in version 3.0.0-next.10 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 3.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add log/slog for logging
2 participants