asyncer-io / r2dbc-mysql

Reactive Relational Database Connectivity for MySQL. The official successor to mirromutth/r2dbc-mysql(dev.miku:r2dbc-mysql).
https://r2dbc.io
Apache License 2.0
195 stars 21 forks source link

Add logging for parameters #165

Closed mirromutth closed 7 months ago

mirromutth commented 8 months ago

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:

Result:

More human-friendly SQL debugging logging.

mirromutth commented 8 months ago

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