-
Notifications
You must be signed in to change notification settings - Fork 41
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
Use the context logger, if available. #180
base: main
Are you sure you want to change the base?
Conversation
This allows use of a non-global logger for finer grained control.
internal/rows/rows.go
Outdated
@@ -68,6 +68,7 @@ var _ driver.RowsColumnTypeLength = (*rows)(nil) | |||
var _ dbsqlrows.Rows = (*rows)(nil) | |||
|
|||
func NewRows( | |||
ctx context.Context, |
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.
If the only thing we are using ctx for is to extract a logger. I would rather pass in a logger as the last argument to NewRows and ensure that dbsqllog.AddContext handles a nil first argument.
logger/logger.go
Outdated
@@ -123,9 +124,24 @@ func Err(err error) *zerolog.Event { | |||
return Logger.Err(err) | |||
} | |||
|
|||
// Ctx returns a DBSQLLogger from the provided context. If no logger is found, | |||
// the default logger is returned. | |||
func Ctx(ctx context.Context) *DBSQLLogger { |
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.
If find this function name a bit confusing. I know that naming things here is complicated by the use of the noun context and the type context but it would be good to have a function name that more clearly tells you what it is doing. Maybe something like FromCtx? I'm open to suggestions.
- Don't pass Context directly into NewRows - Rename function for retrieving logger from Context
Hi @rcypher-databricks , thanks for the review (and apologies for radio silence). I think I've addressed the feedback, let me know if you see anything else that could be improved. |
This allows use of a non-global logger for finer grained control.