Skip to content

2.13.5 - Use logging metadata when logging queries

Latest
Compare
Choose a tag to compare
@penny-for-vapor penny-for-vapor released this 29 May 17:14
0b72fa8

What's Changed

Use logging metadata when logging queries by @gwynne in #266

When a query is executed, the actual SQL query and its accompanying array of bound parameters (if any) are now logged as structured metadata on the logger using a generic message, rather than the query and bindings being the message. This follows the recommended guidelines for logging in libraries. Credit goes to @MahdiBM for the original suggestion.

Before:

2024-05-29T00:00:00Z debug codes.vapor.fluent : database-id=psql [PostgresKit] SELECT * FROM foo WHERE a=$1 [["bar"]]

After:

2024-05-29T00:00:00Z debug codes.vapor.fluent : database-id=psql sql=SELECT * FROM foo WHERE a=$1 binds=["bar"] [PostgresKit] Executing query
This patch was released by @gwynne

Full Changelog: 2.13.4...2.13.5