Skip to content

Commit

Permalink
Use logging metadata when logging queries (#266)
Browse files Browse the repository at this point in the history
Use logging metadata for logging queries
  • Loading branch information
gwynne committed May 29, 2024
1 parent 75004d9 commit 0b72fa8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/PostgresKit/PostgresDatabase+SQL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension PostgresSQLDatabase: SQLDatabase, PostgresDatabase {
let (sql, binds) = self.serialize(query)

if let queryLogLevel = self.queryLogLevel {
self.logger.log(level: queryLogLevel, "\(sql) [\(binds)]")
self.logger.log(level: queryLogLevel, "Executing query", metadata: ["sql": .string(sql), "binds": .array(binds.map { .string("\($0)") })])
}
return self.eventLoop.makeCompletedFuture {
var bindings = PostgresBindings(capacity: binds.count)
Expand All @@ -69,7 +69,7 @@ extension PostgresSQLDatabase: SQLDatabase, PostgresDatabase {
let (sql, binds) = self.serialize(query)

if let queryLogLevel = self.queryLogLevel {
self.logger.log(level: queryLogLevel, "\(sql) [\(binds)]")
self.logger.log(level: queryLogLevel, "Executing query", metadata: ["sql": .string(sql), "binds": .array(binds.map { .string("\($0)") })])
}

var bindings = PostgresBindings(capacity: binds.count)
Expand Down

0 comments on commit 0b72fa8

Please sign in to comment.