Skip to content

Commit

Permalink
Add target context to Postgres notice logs (#1606)
Browse files Browse the repository at this point in the history
Adds a `target` field to the Postgres notice logs and filters based on that target, just like how the query logs do it.
  • Loading branch information
dbeckwith committed Jan 4, 2022
1 parent dec0ed1 commit d901694
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sqlx-core/src/postgres/connection/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit d901694

Please sign in to comment.