Skip to content

4.5.2 - Use structured logging (metadata) when logging queries

Latest
Compare
Choose a tag to compare
@penny-for-vapor penny-for-vapor released this 29 May 17:11
f35a863

What's Changed

Use structured logging (metadata) when logging queries by @gwynne in #110

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=sqlite [SQLiteKit] SELECT * FROM foo WHERE a=?1 [["bar"]]

After:

2024-05-29T00:00:00Z debug codes.vapor.fluent : database-id=sqlite sql=SELECT * FROM foo WHERE a=?1 binds=["bar"] [SQLiteKit] Executing query

Reviewers

Thanks to the reviewers for their help:

This patch was released by @gwynne

Full Changelog: 4.5.1...4.5.2