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

Add logging for parameters #165

Merged
merged 3 commits into from
Jan 23, 2024
Merged

Add logging for parameters #165

merged 3 commits into from
Jan 23, 2024

Conversation

mirromutth
Copy link
Contributor

@mirromutth mirromutth commented Dec 15, 2023

Motivation:

See also #138 .

When driver executing a text statement (no binding), log will like:

2023-12-31 | 23:59:59.999 | reactor-tcp-nio-1    | DEBUG | i.a.r2dbc.mysql.QUERY | Executing statement [SELECT 1]

When user is using client-preparing statements, log will like:

2023-12-31 | 23:59:59.999 | reactor-tcp-nio-1    | DEBUG | i.a.r2dbc.mysql.QUERY | Executing statement [SELECT value FROM test WHERE id=?] with [1]

When user is using server-preparing statements, log will like:

2023-12-31 | 23:59:59.999 | reactor-tcp-nio-1    | DEBUG | i.a.r2dbc.mysql.QUERY | Executing statement [INSERT INTO test VALUES(DEFAULT,?)]
2023-12-31 | 23:59:59.999 | reactor-tcp-nio-1    | DEBUG | i.a.r2dbc.mysql.QUERY | Prepared statement 1 [INSERT INTO test VALUES(DEFAULT,?)]
2023-12-31 | 23:59:59.999 | reactor-tcp-nio-1    | DEBUG | i.a.r2dbc.mysql.QUERY | Executing prepared statement 1 with [10]

Modification:

  • Makes all implementation of AbstractMySqlParameter need to override toString.
  • Add some descriptions of statements logging in README

Result:

More human-friendly SQL debugging logging.

@mirromutth mirromutth marked this pull request as ready for review December 15, 2023 08:58
@mirromutth mirromutth requested a review from jchrys December 15, 2023 08:58
Copy link
Collaborator

@jchrys jchrys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

However, I'm concerned about the breaking change(*MySqlParameter#toString exposes its value, Debug level Query Logger exposes params). Suggest merging with the next minor version update or log with params only when trace level is enabled. Let's discuss before merging.

@jchrys jchrys added this to the 1.1.0/0.10.0 milestone Dec 18, 2023
@mirromutth
Copy link
Contributor Author

I fixed a little miss in the README, and I added an override of toString() in the example of MySqlParameter.

@mirromutth mirromutth requested a review from jchrys December 20, 2023 09:26
@mirromutth mirromutth added the enhancement New feature or request label Dec 20, 2023
Copy link
Contributor

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mirromutth mirromutth force-pushed the feature/issues-138 branch 2 times, most recently from f6b099f to 93ffaba Compare January 17, 2024 08:21
@jchrys jchrys modified the milestones: 1.1.0/0.10.0, 1.0.7/0.9.8 Jan 18, 2024
- Correct parameter interface from `Parameter` to `MySqlParameter`
- Override `toString()` in the implementation of `MySqlParameter`
@mirromutth mirromutth merged commit 8ec8b97 into trunk Jan 23, 2024
12 checks passed
@mirromutth mirromutth deleted the feature/issues-138 branch January 23, 2024 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants