From 817e53d0501a6bd35c58d0690ca27e97df2f37f7 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 28 May 2024 18:25:44 -0500 Subject: [PATCH] Use logging metadata for logging queries --- Sources/PostgresKit/PostgresDatabase+SQL.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/PostgresKit/PostgresDatabase+SQL.swift b/Sources/PostgresKit/PostgresDatabase+SQL.swift index ed04ccb..a3d996b 100644 --- a/Sources/PostgresKit/PostgresDatabase+SQL.swift +++ b/Sources/PostgresKit/PostgresDatabase+SQL.swift @@ -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) @@ -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)