Skip to content

add capability to log query parameters (bindings) values #278

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

Closed
62mkv opened this issue May 5, 2020 · 4 comments
Closed

add capability to log query parameters (bindings) values #278

62mkv opened this issue May 5, 2020 · 4 comments
Labels
status: ideal-for-contribution An issue that a contributor can help us with status: in-progress An issue that is currently being worked on type: enhancement A general enhancement

Comments

@62mkv
Copy link

62mkv commented May 5, 2020

Feature Request

Describe the solution you'd like

I'd like to be able to specify logging level (say, io.r2dbc.postgresql.PARAM) which, when set to DEBUG or TRACE, would enable logging of parameters.

Describe alternatives you've considered

r2bc-proxy is an alternative, but seems to be a big overhead for such a simple use-case

Teachability, Documentation, Adoption, Migration Strategy

A mention in the README should suffice as a documentation

@62mkv 62mkv changed the title add capability to log parameter (binding) values add capability to log query parameters (bindings) values May 5, 2020
@mp911de
Copy link
Collaborator

mp911de commented May 5, 2020

We do not record parameter values in a canonical format that is suitable for logging. When calling bind(…), we run the bind value through the codec and the result is a Publisher<ByteBuf>. Therefore, we cannot really print any parameters during the execution.

We could add trace logging to the bind methods so that parameters get logged at the time of their binding.

@62mkv
Copy link
Author

62mkv commented May 5, 2020

that would be great!

@mp911de
Copy link
Collaborator

mp911de commented May 5, 2020

Feel free to submit a pull request.

@mp911de mp911de added status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement labels May 5, 2020
@ttddyy
Copy link
Contributor

ttddyy commented May 5, 2020

FYI, with r2dbc-proxy, you can do something like this:

MethodExecutionInfoFormatter formatter = new MethodExecutionInfoFormatter().addConsumer((execInfo, sb) -> {
  sb.append("params=");
  sb.append(StringUtils.arrayToCommaDelimitedString(execInfo.getMethodArgs()));
});

ConnectionFactory proxyConnectionFactory = 
  ProxyConnectionFactory.builder(connectionFactory)
    .listener(new LifeCycleListener() {
      @Override
      public void beforeBindOnStatement(MethodExecutionInfo methodExecutionInfo) {
        logger.info(formatter.format(methodExecutionInfo));
      }
      @Override
      public void beforeBindNullOnStatement(MethodExecutionInfo methodExecutionInfo) {
        logger.info(formatter.format(methodExecutionInfo));
      }
    })
    .build();

62mkv pushed a commit to 62mkv/r2dbc-postgresql that referenced this issue Jul 30, 2020
@62mkv 62mkv mentioned this issue Jul 30, 2020
4 tasks
62mkv pushed a commit to 62mkv/r2dbc-postgresql that referenced this issue Jul 30, 2020
@mp911de mp911de added this to the 0.8.5.RELEASE milestone Jul 31, 2020
@mp911de mp911de added the status: in-progress An issue that is currently being worked on label Jul 31, 2020
@mp911de mp911de removed this from the 0.8.5.RELEASE milestone Sep 7, 2020
mp911de added a commit that referenced this issue Oct 15, 2020
Adopt to ConnectionContext. Tweak log message wording. Defer Objects.toString(…) until actual logging happens.

[#278][#309]
mp911de pushed a commit that referenced this issue Oct 15, 2020
mp911de added a commit that referenced this issue Oct 15, 2020
Adopt to ConnectionContext. Tweak log message wording. Defer Objects.toString(…) until actual logging happens.

[#278][#309]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with status: in-progress An issue that is currently being worked on type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants