-
-
Notifications
You must be signed in to change notification settings - Fork 267
refactor: replace usages of golang.org/x/exp with stdlib
#1828
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
Merged
tolgaozen
merged 1 commit into
Permify:master
from
Juneezee:refactor/replace-experimental-with-stdlib
Dec 7, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the usage of logging methods in
log/slog.The standard library
log/slogpackage does not haveslog.Warnandslog.Infomethods directly. Instead, logging at different levels should use aslog.Loggerinstance orslog.Logwith the appropriateslog.Level.Apply this diff to fix the logging statements:
func setDefaultQueryExecMode(config *pgx.ConnConfig) { // Default mode if no specific mode is found in the connection string defaultMode := "cache_statement" // Iterate through the map keys to check if any are mentioned in the connection string for key := range queryExecModes { if strings.Contains(config.ConnString(), "default_query_exec_mode="+key) { config.DefaultQueryExecMode = queryExecModes[key] - slog.Info("setDefaultQueryExecMode", slog.String("mode", key)) + slog.Log(context.Background(), slog.LevelInfo, "setDefaultQueryExecMode", slog.String("mode", key)) return } } // Set to default mode if no matching mode is found config.DefaultQueryExecMode = queryExecModes[defaultMode] - slog.Warn("setDefaultQueryExecMode", slog.String("mode", defaultMode)) + slog.Log(context.Background(), slog.LevelWarn, "setDefaultQueryExecMode", slog.String("mode", defaultMode)) } func setPlanCacheMode(config *pgx.ConnConfig) { // Default plan cache mode const defaultMode = "auto" // Extract connection string connStr := config.ConnString() planCacheMode := defaultMode // Check for specific plan cache modes in the connection string for key, value := range planCacheModes { if strings.Contains(connStr, "plan_cache_mode="+key) { if key == "disable" { delete(config.Config.RuntimeParams, "plan_cache_mode") - slog.Info("setPlanCacheMode", slog.String("mode", "disabled")) + slog.Log(context.Background(), slog.LevelInfo, "setPlanCacheMode", slog.String("mode", "disabled")) return } planCacheMode = value - slog.Info("setPlanCacheMode", slog.String("mode", key)) + slog.Log(context.Background(), slog.LevelInfo, "setPlanCacheMode", slog.String("mode", key)) break } } // Set the plan cache mode config.Config.RuntimeParams["plan_cache_mode"] = planCacheMode if planCacheMode == defaultMode { - slog.Warn("setPlanCacheMode", slog.String("mode", defaultMode)) + slog.Log(context.Background(), slog.LevelWarn, "setPlanCacheMode", slog.String("mode", defaultMode)) } }There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log/slogpackage does haveslog.Warnandslog.Info.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Juneezee, thank you for the correction. You are absolutely right; the
log/slogpackage does haveslog.Warnandslog.Infomethods. I apologize for the confusion.✏️ Learnings added