fix(logging): make query logging obey level setting for `sqlx::query` target
@@ -31,8 +31,10 @@ impl<'q> QueryLogger<'q> {
self.settings.statements_level
};
- if let Some(lvl) = lvl.to_level() {
- if lvl <= log::STATIC_MAX_LEVEL && lvl <= log::max_level() {
+ if let Some(lvl) = lvl
+ .to_level()
+ .filter(|lvl| log::log_enabled!(target: "sqlx::query", *lvl))
+ {
let mut summary = parse_query_summary(&self.sql);
let sql = if summary != self.sql {
@@ -65,7 +67,6 @@ impl<'q> QueryLogger<'q> {
}
}
}
-}
impl<'q> Drop for QueryLogger<'q> {
fn drop(&mut self) {
