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

Actually support query logging #326

Merged
merged 2 commits into from
May 29, 2024
Merged

Actually support query logging #326

merged 2 commits into from
May 29, 2024

Conversation

gwynne
Copy link
Member

@gwynne gwynne commented May 27, 2024

These changes are now available in 4.9.0

Now supports query logging with the same semantics as the other drivers. When a query is executed with query logging enabled at or above the logger's current log level, the actual SQL query and its accompanying array of bound parameters (if any) are logged as structured metadata on the logger using a generic 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=mysql [MySQLKit] SELECT * FROM foo WHERE a=? [["bar"]]

After:

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

Also bumps dependency minimums.

@gwynne gwynne added enhancement New feature or request semver-minor Contains new APIs labels May 27, 2024
@gwynne gwynne requested review from 0xTim, MahdiBM and ptoffy May 27, 2024 19:14
Copy link

codecov bot commented May 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.46%. Comparing base (dd21809) to head (ee0c7a3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #326      +/-   ##
==========================================
+ Coverage   66.04%   66.46%   +0.41%     
==========================================
  Files           9        9              
  Lines         321      325       +4     
==========================================
+ Hits          212      216       +4     
  Misses        109      109              
Files Coverage Δ
Sources/MySQLKit/MySQLDatabase+SQL.swift 77.41% <100.00%> (+3.34%) ⬆️

@gwynne gwynne merged commit ac03d7c into main May 29, 2024
24 of 25 checks passed
@gwynne gwynne deleted the fix-query-logging branch May 29, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request semver-minor Contains new APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants