From 49928ddf81fe99137c565aa1ef43fd67282ee902 Mon Sep 17 00:00:00 2001 From: Daniel Beckwith Date: Sun, 2 Jan 2022 23:18:20 +0000 Subject: [PATCH] Add target context to Postgres notice logs Adds a `target` field to the Postgres notice logs and filters based on that target, just like how the query logs do it. --- sqlx-core/src/postgres/connection/stream.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sqlx-core/src/postgres/connection/stream.rs b/sqlx-core/src/postgres/connection/stream.rs index 950d8d0969..59b5289b8e 100644 --- a/sqlx-core/src/postgres/connection/stream.rs +++ b/sqlx-core/src/postgres/connection/stream.rs @@ -146,12 +146,13 @@ impl PgStream { PgSeverity::Log => Level::Trace, }; - if lvl <= log::STATIC_MAX_LEVEL && lvl <= log::max_level() { + if log::log_enabled!(target: "sqlx::postgres::notice", lvl) { log::logger().log( &log::Record::builder() .args(format_args!("{}", notice.message())) .level(lvl) .module_path_static(Some("sqlx::postgres::notice")) + .target("sqlx::postgres::notice") .file_static(Some(file!())) .line(Some(line!())) .build(),